Martin,

    The "fgDeinitialize" was added because we added the possibility of "freeglut" returning cleanly from "glutMainLoop" and the program continuing its execution.  Somebody wanted to be able to reinitialize "freeglut" and start the whole process over again.

        - John


On 12/14/2011 4:30 AM, Martin Payne wrote:
Hi Dee, all,

On 13/12/2011 11:36, Diederick C. Niehorster wrote:
I didn't see any errors in the debugger output. Also no problem with a
release build with everything unchanged from their defaults.
    

Interesting. I have found the same problem whether I use VS 2008, 2010, or MinGW, release or debug build. It only happens in 2.8.0, not 2.6.0.

I've done some more digging, and I found the access violation happens when fgCloseWindow() is called *after* the CRT exit() function has been called. It happens on the call wglMakeCurrent(NULL, NULL) on line 1540 of "freeglut_window.c", but any OpenGL call seems to cause an access violation at this point. The call stack is as follows:
freeglut.dll!fgCloseWindow(tagSFG_Window * window=0x00171d88)  Line 1539
freeglut.dll!fgDestroyWindow(tagSFG_Window * window=0x00171d88)  Line 224 + 0x9 bytes
freeglut.dll!fgDestroyStructure()  Line 377 + 0xb bytes
freeglut.dll!fgDeinitialize()  Line 424
freeglut.dll!_CRT_INIT(void * hDllHandle=0x72120000, unsigned long dwReason=0, void * lpreserved=0x00000001)  Line 449
freeglut.dll!__DllMainCRTStartup(void * hDllHandle=0x72120000, unsigned long dwReason=0, void * lpreserved=0x00000001)  Line 560 + 0x11 bytes
freeglut.dll!_DllMainCRTStartup(void * hDllHandle=0x72120000, unsigned long dwReason=0, void * lpreserved=0x00000001)  Line 510 + 0x11 bytes
ntdll.dll!77499930()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!774b8fba()
ntdll.dll!774b8e5c()
kernel32.dll!750a79f5()
msvcr90d.dll!__crtExitProcess(int status=0)  Line 732
msvcr90d.dll!doexit(int code=0, int quick=0, int retcaller=0)  Line 644 + 0x9 bytes
msvcr90d.dll!exit(int code=0)  Line 412 + 0xd bytes
I think the problem is that we are making calls to the OpenGL library after it has been unloaded from the process' virtual address space. Comparing 2.8.0 with 2.6.0 I see that we have added a "atexit(fgDeinitialize)" on line 393 of "freeglut_init.c" (revision 897). Commenting the atexit() out results in the application exiting cleanly, and explains why the issue happens only in 2.8.0. I don't have a proposed fix as I don't know what exactly needs to be cleaned up at this point, and what the consequences of not cleaning it up would be.

Regards,
Martin
------------------------------------------------------------------------------ Cloud Computing - Latest Buzzword or a Glimpse of the Future? This paper surveys cloud computing today: What are the benefits? Why are businesses embracing it? What are its payoffs and pitfalls? http://www.accelacomm.com/jaw/sdnl/114/51425149/
_______________________________________________ Freeglut-developer mailing list Freeglut-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freeglut-developer