[PATCH] FreeGLUT causes segfault in recent Xorg GL driver

Ian Romanick idr at freedesktop.org
Wed Nov 12 12:57:26 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Florian Echtler wrote:
> Hi everyone,
> 
> I've just switched to a recent Xorg build (git checkout from last
> Friday). I'm using the radeon driver on a Radeon Mobility X1400, and
> GLUT-based applications run with 3D acceleration when I start them with
> the GLUT implementation from MESA. However, when I try freeglut rev. 749
> instead (just by replacing the libraries), the following happens:
> 
> Program received signal SIGSEGV, Segmentation fault.
> ...
> (gdb) bt
> #0  0xb61df5a2 in driBindContext (context=0xb390ff40, draw=0x0, 
>   read=0x0) at dri_glx.c:457
> #1  0xb61be38a in MakeContextCurrent (dpy=0x83d8438, draw=54525954, 
>   read=54525954, gc=0xb3903530, pre13=0) at glxcurrent.c:391
> #2  0xb534ead2 in fgOpenWindow () from /usr/lib/libglut.so.3
> #3  0xb534ce05 in fgCreateWindow () from /usr/lib/libglut.so.3
> #4  0xb534e1fa in glutCreateWindow () from /usr/lib/libglut.so.3
> ...
> (gdb) 
> 
> Same backtrace occurs with a freshly compiled Freeglut test program.
> 
> I managed to fix this bug with the following one-line patch:
> 
> --- src/freeglut_window.c	(Revision 749)
> +++ src/freeglut_window.c	(Arbeitskopie)
> @@ -759,10 +759,9 @@
>      XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
>                       &fgDisplay.DeleteWindow, 1 );
>  
> -    glXMakeContextCurrent(
> +    glXMakeCurrent(
>          fgDisplay.Display,
>          window->Window.Handle,
> -        window->Window.Handle,
>          window->Window.Context
>      );
>  
> Unfortunately, I don't know a) which side effects this might have (from 
> looking at the macro, it seems that there shouldn't be any) and b) I'm 
> also unsure whether this patch is appropriate for older X releases.

In this case there is no functional change.  As Michel pointed out,
glXMakeContextCurrent is on available with GLX 1.3.  There is a similar
function that is part of the GLX_SGI_make_current_read extension.
However, if you know that the read and draw drawables will always be the
same, as is the case here, glXMakeCurrent read should be used for
broader compatibility.

To summarize, your proposed fix is correct.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkkbQzYACgkQX1gOwKyEAw92SACfY4A7M1FjwEwjwkrYTPJOWLVb
4rUAnjxLeXRmvnJHP8ojL78ONYCff0dw
=RiPT
-----END PGP SIGNATURE-----



More information about the xorg mailing list