We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2164

Summary: Debian bug report: SDL_SetVideoMode segfault if GLX extension are missing
Product: SDL Reporter: manuel.montezelo
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: 2.0.0   
Hardware: x86_64   
OS: Linux   

Description manuel.montezelo 2013-10-19 18:47:18 UTC
Hello,

I'm reviewing old patches for SDL 1.2 which I don't think that were applied upstream, hoping that they can still increase the quality of SDL2.

Bug report in Debian http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541365
-------------------
If the X server has no GLX extension, SDL_SetVideoMode() segfault. Please
see
#537487.

To reproduct the problem you can do something like:
 rm -rf /usr/lib/dri

Restart X and enjoy:

linda:~/public_html/oscs.git/app/models (master)$glxinfo
name of display: :0.0
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Error: couldn't find RGB GLX visual or fbconfig

Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".
Xlib:  extension "GLX" missing on display ":0.0".

Then you can try to start opencity.

The attached patch fix the issue.
-------------------
Index: src/video/x11/SDL_x11gl.c
===================================================================
--- src/video/x11/SDL_x11gl.c.orig
+++ src/video/x11/SDL_x11gl.c
@@ -70,7 +70,12 @@
 	/* It takes a bit of care to be fool-proof about parsing the
 	 * OpenGL extensions string. Don't be fooled by sub-strings, etc.
 	 */
-	
+
+  /* http://bugs.debian.org/537487 */
+  if (extensions == NULL) {
+    return 0;
+  }
+
 	start = extensions;
 	
 	for (;;) {

-------------------

The code in http://hg.libsdl.org/SDL/file/6073ad385c9b/src/video/x11/SDL_x11opengl.c of the little fragment in the patch still matches, but I think that the check immediately before of the lines shown already checks for this situation.

if (!extensions)
        return SDL_FALSE;

So please see if this is useful, otherwise just close the bug report.
Comment 1 Ryan C. Gordon 2013-10-20 06:53:20 UTC
(In reply to manuel.montezelo from comment #0)
> The code in
> http://hg.libsdl.org/SDL/file/6073ad385c9b/src/video/x11/SDL_x11opengl.c of
> the little fragment in the patch still matches, but I think that the check
> immediately before of the lines shown already checks for this situation.

Correct, this patch isn't needed, as we already do that check in SDL 2.0.

(Thanks for following up about this!)

--ryan.