SDL bug (?) at SDL_Quit() with glew

Hello!

I’m having problems using glew (http://glew.sf.net) opengl extension lib
with SDL.

SDL with OpenGL works well.

Glew itself (when using glut) works just fine, including the glewinfo
program.

When I mix glew AND SDL, I start getting crashes at SDL_Quit()!

But… it’s not that easy… this only happens when using DRI drivers! When
using Nvidia’s binary only drivers, this crash doesn’t happen!

Where should I start digging this ?

I’m using Debian GNU/Linux (unstable). SDL 1.2.5. Gcc 3.2.2. XFree86
4.2.99.4. Linux 2.4.20ck2.

Here are a couple of gdb backtraces of crashing sdl+glew program:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 1358)]
0x080599a0 in _glewErrorString ()
(gdb) bt
#0 0x080599a0 in _glewErrorString ()
#1 0x4005722a in X11_GL_Shutdown () from /usr/lib/libSDL-1.2.so.0
#2 0x4005a232 in X11_CheckMouseMode () from /usr/lib/libSDL-1.2.so.0
#3 0x4005b8b5 in X11_CheckMouseMode () from /usr/lib/libSDL-1.2.so.0
#4 0x400523a4 in SDL_VideoQuit () from /usr/lib/libSDL-1.2.so.0
#5 0x4002e531 in SDL_QuitSubSystem () from /usr/lib/libSDL-1.2.so.0
#6 0x4002e5e9 in SDL_Quit () from /usr/lib/libSDL-1.2.so.0
#7 0x0804b358 in main () at test.cpp:43

and another:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 1374)]
0x0805e940 in glXWaitVideoSyncSGI ()
(gdb) bt
#0 0x0805e940 in glXWaitVideoSyncSGI ()
#1 0x05e6a8a3 in ?? ()
#2 0x4017b232 in X11_CheckMouseMode () from /usr/lib/libSDL-1.2.so.0
#3 0x4017c8b5 in X11_CheckMouseMode () from /usr/lib/libSDL-1.2.so.0
#4 0x401733a4 in SDL_VideoQuit () from /usr/lib/libSDL-1.2.so.0
#5 0x4014f531 in SDL_QuitSubSystem () from /usr/lib/libSDL-1.2.so.0
#6 0x4014f5e9 in SDL_Quit () from /usr/lib/libSDL-1.2.so.0
#7 0x08059915 in main (argc=1, argv=0xbffffa84) at src/glewinfo.c:2251

You can find a sample program demonstrating the bug from here:
http://nrg.joroinen.fi/sdlglewbug.tar.gz

it’s really a simple program, so the bug needs to be somewhere else…

I’ve discussed about this with glew author, but we didn’t find out anything
that could cause this…

If you have any ideas, please comment!

– Pasi K?rkk?inen

                               ^
                            .     .
                             Linux
                          /    -    \
                         Choice.of.the
                       .Next.Generation.