SDL segfaults in SDL_GL_Shutdown() with glew.. need help

Hello!

I’ve had problems with SDL+glew for many months now and I finally had time
to debug it more… and I need some help from you!

I’m using Linux, Debian (unstable). The bug which I am talking about only
happens when you are using Mesa-based DRI-OpenGL-drivers, not when using
Nvidia’s drivers.

So, when you use glew (http://glew.sf.net, OpenGL extension handler library)
in your SDL-program, and you just link your program with glew (you don’t
need to initialize glew), SDL_GL_Shutdown() starts to segfault!

You can find a very simple demo-program from http://nrg.joroinen.fi/sdl-glew-bug.tar.gz
If you are using DRI drivers (I have Matrox G400 + Debian’s XFree86 4.2.1)
the demo-program segfaults!

The segfault happens in SDL_GL_Shutdown() when
this->gl_data->glXReleaseBuffersMESA() is called. That also explains why the
segfault does not happen with Nvidia’s drivers (Mesa-specific function
call).

The demo-program does not initialize or use glew in any way. Just
linking with glew.o (or .so) is enough to “start” the segfault… If you
remove linking with glew.o from the demo-program, the segfault does not
happen anymore…

Any ideas?

– Pasi K?rkk?inen

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

I debugged this more, and also discussed with DRI developers, and we noticed
that there might be a bug in SDL’s OpenGL init…

Code from X11_GL_LoadLibrary():

this->gl_data->glXReleaseBuffersMESA =
(void (*)(Display *, GLXDrawable)) dlsym( handle, “glXReleaseBuffersMESA” );

And then in X11_GL_Shutdown() there is:

if( this->gl_data->glXReleaseBuffersMESA ) {
this->gl_data->glXReleaseBuffersMESA(GFX_Display, SDL_Window);
}

glxReleaseBuffersMESA() should NOT be called when Mesa is loaded as
libGL.so!

glxReleaseBuffersMESA() should NOT be called before checking if it is
supported as a GLX extension!

What is the meaning of glXReleaseBuffersMESA() in SDL ? I removed the call
to it and now everything runs just fine without crashing…

Thanks!

– Pasi K?rkk?inen

                               ^
                            .     .
                             Linux
                          /    -    \
                         Choice.of.the
                       .Next.Generation.On Mon, Mar 17, 2003 at 08:27:43PM +0200, Pasi K?rkk?inen wrote:

Hello!

I’ve had problems with SDL+glew for many months now and I finally had time
to debug it more… and I need some help from you!

I’m using Linux, Debian (unstable). The bug which I am talking about only
happens when you are using Mesa-based DRI-OpenGL-drivers, not when using
Nvidia’s drivers.

So, when you use glew (http://glew.sf.net, OpenGL extension handler library)
in your SDL-program, and you just link your program with glew (you don’t
need to initialize glew), SDL_GL_Shutdown() starts to segfault!

You can find a very simple demo-program from http://nrg.joroinen.fi/sdl-glew-bug.tar.gz
If you are using DRI drivers (I have Matrox G400 + Debian’s XFree86 4.2.1)
the demo-program segfaults!

The segfault happens in SDL_GL_Shutdown() when
this->gl_data->glXReleaseBuffersMESA() is called. That also explains why the
segfault does not happen with Nvidia’s drivers (Mesa-specific function
call).

The demo-program does not initialize or use glew in any way. Just
linking with glew.o (or .so) is enough to “start” the segfault… If you
remove linking with glew.o from the demo-program, the segfault does not
happen anymore…