Serious Bug: Included demos will not clean up after exit

Enrico
Posts: 42
Joined: Thu May 17, 2007 9:34 am
Location: Stuttgart, Germany

Serious Bug: Included demos will not clean up after exit

Post by Enrico »

Hi,

I just found out that the included demos do not clean up at exit! :evil:
Each demo application has a exitPhysics()-method and/or a destructor, which is never called when exiting an application with the 'q'-button. What the current demos are doing:

Code: Select all

Create *Application instance
Run Application
[color=#FF0000]Exit[/color]

Delete *Application instance
So the instances get never deleted, no dtors are called, because you already exited the application. Great! :evil:


Solutions:
1) Call glutLeaveMainLoop() instead of exit(), however this is not available on old glut implementations. This should really be no problem, most distributions nowadays are using FreeGlut, which has this function.
or
2) If you do not want to go with 1), then please add

Code: Select all

virtual void exitPhysics() {}
to DemoApplication and call it right before exit(). This way you leave only the application instance in memory and the applications get a chance to clean up.

I have some more bugs to report, just need to create some clean test cases and investigate some more.


Best regards,
Enrico


PS: Why don't you use the sf.net Bug Tracker? :roll:
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Serious Bug: Included demos will not clean up after exit

Post by Dirk Gregorius »

You could also use atexit() from the CRT.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Serious Bug: Included demos will not clean up after exit

Post by Erwin Coumans »

This is a well known issue with Glut indeed, and Bullet already has a workaround for FreeGlut users:
Make sure BT_USE_FREEGLUT is defined. See Bullet\Demos\AllBulletDemos\Main.cpp and Bullet\Demos\OpenGL\DemoApplication.cpp.

All memory allocations in the Bullet core library go through one path (LinearMath/btAlignedAllocator.cpp). There is a empty 'memoryleak' demo to detect any leaks related to btAlignedAlloc/Free. When switching demos, the previous demo is cleaned up using exitPhysics.
PS: Why don't you use the sf.net Bug Tracker?
Good point. We consider starting to use Google Code issue tracker, just for the tracking. SF has too many advertisements. It is better if we keep the bug/issue discussion all here, so users/developers should not submit bugs directly into a bug tracker. We can link a forum topic to an issue to make it clear that the issue is being worked on.

All discussion should stay in one location: this forum.
Hope this helps,
Erwin
Enrico
Posts: 42
Joined: Thu May 17, 2007 9:34 am
Location: Stuttgart, Germany

Re: Serious Bug: Included demos will not clean up after exit

Post by Enrico »

Erwin Coumans wrote:This is a well known issue with Glut indeed, and Bullet already has a workaround for FreeGlut users:
Make sure BT_USE_FREEGLUT is defined. See Bullet\Demos\AllBulletDemos\Main.cpp and Bullet\Demos\OpenGL\DemoApplication.cpp.
So maybe this should be added to the configure-script?
All memory allocations in the Bullet core library go through one path (LinearMath/btAlignedAllocator.cpp). There is a empty 'memoryleak' demo to detect any leaks related to btAlignedAlloc/Free. When switching demos, the previous demo is cleaned up using exitPhysics.
Memory is just one part. Another part are open files (which might be closed by exit()) and open IPC stuff like this.



Best regards,
Enrico