Hello!

I have been debugging a problem I am seeing with SDL when used with glew (glew
is OpenGL extension handler library, http://glew.sf.net).

When you use Mesa-based OpenGL drivers, and your app is using SDL for
OpenGL, and you link your program with glew, _SDL_ starts to segfault in
X11_GL_Shutdown().

The segfault happens when the following code from X11_GL_Shutdown() is run:

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

*segfault*

First I was sure, that the problem/bug is in glew, because the above code starts
to segfault after you link with glew libraries.. without glew everything
works well.

But after talking with DRI developers (Ian Romanick) it seems the real bug
is in SDL.. glew just exposes it somehow.

SDL does not check if the OpenGL driver really supports
glXReleaseBuffersMESA(). SDL should parse the extensions string to see if
the extension is really supported. The code currently (from SDL 1.2.5) is
like this:

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

That is wrong, because for example with my Matrox G400 the driver does NOT
support that extension (if you look "glxinfo", glXReleaseBuffersMESA is not
in the list of supported extensions), but it is included in the Mesa OpenGL
library and dlsym() finds a pointer for it..

Now when that function is called in X11_GL_Shutdown() in SDL it causes the
segfault I'm seeing.

This obviously does not happen with Nvidia's drivers, because they do not include
that function in the libGL.so.

Ian Romanick also stated that glXReleaseBuffersMESA() should not be called
in any case when Mesa is loaded as libGL.so .. any ideas why that piece of
code is in SDL ?

When I remove glXReleaseBuffersMESA() code from SDL everything runs fine!

Really simple application for testing this is available from
http://nrg.joroinen.fi/sdl-glew-bug.tar.gz. It should compile out of the box
and segfault if you are using DRI drivers (at least if segfaults with my
G400 and with couple of other people's G400 too, both Debian and Redhat). 

I really would like to get this solved, because SDL segfaults every time I
try to use it (with glew).


Thanks!


-- Pasi Kärkkäinen
       
                                   ^
                                .     .
                                 Linux
                              /    -    \
                             Choice.of.the
                           .Next.Generation.


-------------------------------------------------------
This SF.net email is sponsored by: Does your code think in ink? 
You could win a Tablet PC. Get a free Tablet PC hat just for playing. 
What are you waiting for?
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to