SDL
SDL copied to clipboard
Windows: crash inside SDL_CreateWindow when unsupported GLES version is requested
When SDL_CreateWindow
is called with SDL_GL_SetAttribute
calls made previously to set up an OpenGL ES context, and the context's version is not supported on the system, SDL_CreateWindow
ends up crashing due to accessing a null window->internal
pointer inside WIN_SetWindowFullscreen
in some code that's meant to destroy the remaining parts of the window and restore the screen after creation failure.
My repro steps:
- open
testgles2.c
and modify this part:
state->gl_major_version = 2;
state->gl_minor_version = 0;
to be this instead:
state->gl_major_version = 3;
state->gl_minor_version = 3;
- run testgles2 through the SDL test visual studio solution.
- Observe a crash.
Here's the crash callstack from the above repro:
> SDL3.dll!WIN_SetWindowFullscreen(SDL_VideoDevice * _this, SDL_Window * window, SDL_VideoDisplay * display, SDL_FullscreenOp fullscreen) Line 1247 C
SDL3.dll!SDL_UpdateFullscreenMode(SDL_Window * window, SDL_FullscreenOp fullscreen, bool commit) Line 1959 C
SDL3.dll!SDL_DestroyWindow_REAL(SDL_Window * window) Line 4083 C
SDL3.dll!SDL_CreateWindowWithProperties_REAL(unsigned int props) Line 2429 C
SDL3.dll!SDL_CreateWindowWithProperties(unsigned int a) Line 164 C
testgles2.exe!SDLTest_CommonInit(SDLTest_CommonState * state) Line 1391 C
testgles2.exe!SDL_main(int argc, char * * argv) Line 746 C
And the crash details from the VS debugger:
Outside of a synthetic repro case, this was observed by someone on an AMD system when attempting to create an OpenGL ES 3.2 context on Windows, which isn't supported by their driver.
I'm not sure if the Windows-specific GL/GLES window creation code should be doing something different on failure, or if the higher level failure cleanup code (which is what my callstack has) should be more robust.