The following code segfaults when using freeglut 2.8.1 and AMD Catalyst drivers 13.12.
int main(int argc, char **argv)
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
From some investigation, the problem appears to be that glutInit uses atexit to register shutdown code, and at a later point (I think the first time a glX function is called), the fglrx driver also registers some shutdown code with __cxa_atexit. Because it is registered later, it runs first, and presumably puts things into a state where fgDeinitialize ends up corrupting data. The actual segfault doesn't seem to have fgDeinitialize in the stack, but presumably it is corrupting something that then breaks later shutdown code.
If glutMainLoop is called, then it explicitly calls fgDeinitialize before main() returns, and all is well (fgDeinitialize still runs at shutdown, but it doesn't do anything since freeglut has already shut down). Similarly, if I manually call fgDeinitialize, then there is no segfault.
I've filed this as a bug in AMD's unofficial bugzilla (http://ati.cchtml.com/show_bug.cgi?id=979), but who knows if it will be fixed. As a workaround, the atexit registration should presumably be delayed until after the first GLX call (or possibly use a second atexit call, if there is no guarantee that there will be such a call). Another possibility might be to make a dummy GLX call earlier on, to force the driver to do its own atexit registration.
Log in to post a comment.