-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fairly straightfowrad, programs were randomly seg faulting on exit. This was happening due to GLUT registering a cleanup function via atexit(), which then gets called when exit() is called. The issue happens when exit() is called on a thread other than the GLUT thread, which leads to the exit() call then attempting to cleanup GLUT while the other thread is still using it, which randomly leads to seg faults. Fixing this is slightly annoying. We cannot stop the GLUT thread, as the basic GLUT API (which is used on Mac OS) simply does not offer a way to exit the glutMainLoop() call. Thus the simplest solution is to simply make sure we call exit() on the GLUT thread, which we can fairly easily due via the message queue. That being the case, a new libqb_exit() API was added, which simply regsiters the GLUT exit message and then waits for the program to end. The atexit() handler then runs on the GLUT thread and everything works out fine. In the future we probably should redo the exit logic a bit so that all the threads are actually stopped/joined to ensure the exit process is consistent, however this is good enough for now. Also, there's plenty of error states which call exit() which I did not address.
- Loading branch information
Showing
7 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters