OpenGL Shutdown Problem

Started by
22 comments, last by karmalaa 22 years, 10 months ago
Hi guys, upon the close up of an OpenGL sample application of mine, I get a "Invalid Address specified to RtlFreeHeap(...)" error. The stack context in which it happens to some "finalization" code within the G400ICD.dll called from the "exit()" procedure. I really can''t guess why this happens. OpenGL finalization ("wglMakeCurrent(NULL, NULL)", "ReleaseDC(hWhd, hDC)", and "wglDeleteContext(hRC)") and window destruction ("DestroyWindow(hWnd)" and "UnregisterClass()") do their job correcly. However, the problem persist. Is there something I''m missing? Hope someone can spot some Light on this problem of mine... [home page] [e-mail] --- "Lifting shadows off a dream once broken She can turn a drop of water into an ocean"
---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
Advertisement
Well, My shutdown code is something like:

hDC = GetDC(hWnd);
wglMakeCurrent(hDC, NULL);
wglDeleteContext(hRC);
ReleaseDC(hWnd, hDC);

I''m not sure what effect (in your case) wglMakeCurrent(NULL, NULL); would have. Do other OpenGL programs function okay on your hardware?

Dear Anonimous Poster,
according to the official documentation, passing NULL as second argument to "wglMakeCurrent()" make the first one to be ignored. So, using both "wglMakeCurrent(hDC, NULL)" and "wglMakeCurrent(NULL, NULL)" should be equivalent.

I''ve tried, though, and it makes no difference to pass a valid DC pointer as the first argument. The application still "hung up" upon exiting.

BTW, other people''s (such as NeHe) sample code compiles and works perfectly on my computer.





[home page] [e-mail]

---
"Lifting shadows off a dream once broken
She can turn a drop of water into an ocean"
---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
Well what is different about your code than NeHes code?

Are you using any Extensions any special features?

I would try disabling all of my drawing code and as much of my initialization code as I can and try to pinpoint where the error is originating from. Step through the shutdown and examine the return values.

Basically what that error is saying is that it is trying to deallocate a memory heap that either never existed or (more likely) there is a reference to memory that has already been deallocated which it is trying to deallocate again as part of standard cleanup procedures. Since it is being initiated by your video card driver DLL (Im assuming you have a G400?) it might be a context issue.

Try making sure you set device context and rendering context variables to NULL after deleting and releasing them.

Seeya
Krippy
quote:Original post by Krippy2k

Well what is different about your code than NeHes code?



I''ve changed the order in which the window-class and fullscreen switching is done. In general I''ve cleaned up the code a lot. No substantial modification, however.

quote:Original post by Krippy2k

Are you using any Extensions any special features?



No. Not at all.

quote:Original post by Krippy2k

I would try disabling all of my drawing code and as much of my initialization code as I can and try to pinpoint where the error is originating from. Step through the shutdown and examine the return values.



I''ve already checked up on it. Initialization and finalization works perfectly. It is surely a RENDERING CONTEXT issue, since not creating it (and of course not using and not deleting it) make the problem to vanish.

quote:Original post by Krippy2k

Try making sure you set device context and rendering context variables to NULL after deleting and releasing them.



Oh, my God... I really do not dispose twice the same resources and I *HOPE* the videocard driver DLL does not mess up with them. Just joking...

As a general practice, I always reset to NULL the pointers after deleting them.



---
[home page] [e-mail]
---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
Are you using WinNT/2k and/or multiple threads?

And have you tried just for giggles commenting out the wglDeleteContext to see what happens?



quote:Original post by Krippy2k

Are you using WinNT/2k and/or multiple threads?



Yep, I''m developing both under Windows 2000 Professional (SP1) (using Visual .NET - Beta 1) and under Windows NT4 (SP6) (using Visual Studio 6 - SP5). Strangely enough, it works on the first one but not on the second.

I''m currently NOT using any additional thread.

quote:Original post by Krippy2k

And have you tried just for giggles commenting out the wglDeleteContext to see what happens?



Yep. Nothing seems to change. The error still remains...



---
[home page] [e-mail]
---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
I''m getting the same error.

HEAP[lesson2.exe]: Invalid Address specified to RtlFreeHeap( 130000, 1b80e8 )

That''s what I get when NEHE''s lesson 2 program exits. This ONLY happens in the Visual C++ IDE though, outside of it the program runs fine. I''m using VC++ 6, Windows NT 5 (2000). I''ve been having some problems with VC++ lately though, so I''m going to reinstall it and see if that helps.
Supernova I don''t suppose you are running a Matrox video card?
I have a Matrox Millenium as my secondary adapter. My primary is a Voodoo 3 3000.

This topic is closed to new replies.

Advertisement