1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-09-16 09:44:19 +00:00
QB64-PE/internal/c/libqb/include
Matthew Kilgore f7fabda198 Fix random seg faults on exit
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.
2022-11-29 20:04:54 -05:00
..
audio.h Implement _SNDPLAYCOPY enhancement #185 2022-10-05 02:33:44 +05:30
buffer.h Add append-only buffer API 2022-06-11 22:47:06 -04:00
completion.h Add completion API 2022-06-11 22:47:06 -04:00
condvar.h Add generic thread, mutex, and condvar API 2022-06-11 22:47:06 -04:00
filepath.h Revert changes to miniaudio.h, move changes elsewhere 2022-09-08 23:59:19 -04:00
glut-thread.h Fix random seg faults on exit 2022-11-29 20:04:54 -05:00
gui.h Include stdarg.h in gui.h 2022-10-25 04:34:41 +05:30
http.h Add _StatusCode command for HTTP handles 2022-11-20 04:04:02 -05:00
image.h Update test license files 2022-10-25 07:28:35 +05:30
keyhandler.h Move GLUT initialization logic into separate .cpp file 2022-11-29 20:04:53 -05:00
libqb-common.h Fix High-DPI awareness on Windows 2022-08-28 21:44:07 -04:00
mutex.h Add generic thread, mutex, and condvar API 2022-06-11 22:47:06 -04:00
thread.h Add generic thread, mutex, and condvar API 2022-06-11 22:47:06 -04:00