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 1749

Summary: SDL_GL_CreateContext() causes fatal X11 protocol errors that should just be caught instead...
Product: SDL Reporter: Lee Salzman <lsalzman>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: Linux   
Attachments: modifies SDL_x11opengl.c:X11_GL_CreateContext to filter out any X11 errors before they would cause aborts

Description Lee Salzman 2013-03-10 08:47:49 UTC
Created attachment 1065 [details]
modifies SDL_x11opengl.c:X11_GL_CreateContext to filter out any X11 errors before they would cause aborts

When using SDL_GL_CreateContext() to create a >= 3.0 version or core/forward-compatible context, internally glXCreateContextAttribsARB is used. Mesa in particular seems to be having trouble with this call and returning all sorts of errors, so it is dangerous to poll for the highest GL version by using calls to SDL_GL_CreateContext unless you are sure, a priori, that the call will suceed, defeating the point of its use.

X11 protocol errors are of the following form, with varying details depending on user, but the cause is always SDL_GL_CreateContext as above...

X Error of failed request:  GLXBadFBConfig
  Major opcode of failed request:  153 (GLX)
  Minor opcode of failed request:  34 ()
  Serial number of failed request:  215
  Current serial number in output stream:  221

These sorts of errors can be temporarily filtered out by setting an X11 error handler to catch and ignore them, which is safe with respect to SDL_GL_CreateContext behavior because this function is allowed to return NULL to indicate failure.

A patch is attached to do this temporary filtering/catching of errors generated by trying to use glXCreateContextAttribs and friends...
Comment 1 Sam Lantinga 2013-03-10 12:07:54 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/2aed1beaf5bc