Repository navigation
Conversation
When an extension is not listed in GL_EXTENSIONS, CheckOpenGLExtension falls back to glXQueryExtensionsString(glXGetCurrentDisplay()). Under Wayland SDL uses EGL: there is no GLX context and the GLX entry points returned via SDL_GL_GetProcAddress are unusable stubs, so the result was passed to strstr() and crashed. Only query GLX extensions when SDL's current video driver is x11 (looked up with dlsym, since togl does not link SDL), and skip NULL results. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux with SDL's Wayland video driver, the game crashes with a segmentation fault right after
SDL video target is 'wayland'. This is the crash reported in #395 (and mentioned in #393). Until now the only workaround wasSDL_VIDEODRIVER=x11.Cause
CheckOpenGLExtension_internal()intogl/linuxwin/glentrypoints.cppfalls back toglXQueryExtensionsString(glXGetCurrentDisplay(), 0)when an extension is not inGL_EXTENSIONS. Under Wayland, SDL creates the context with EGL, so there is no GLX context. The GLX entry points returned viaSDL_GL_GetProcAddresscannot be used there, and their result was passed straight tostrstr(), which crashed.Fix
x11.SDL_GetCurrentVideoDriveris looked up once withdlsym, because togl does not link against SDL. If it cannot be found, the old behaviour is kept.NULLdisplay or aNULLextension string instead of passing it tostrstr().Nothing changes for X11 (including XWayland), where the GLX fallback still runs.
Testing
Fedora 44 x86_64, KDE Plasma 6 on Wayland, Intel Arc B390 (Mesa 26.2),
timedemoon ad1_canals_01demo:SDL_VIDEODRIVER=waylandSDL_VIDEODRIVER=x11The same fix has also been in use on a riscv64 board (Milk-V Jupiter, Debian 13, KDE Plasma on Wayland). RISC-V support itself will be a separate PR.
How this was made
I made this together with Claude Code, Anthropic's AI coding assistant. I guided it throughout and kept the change small and limited to the one function that crashed. I tested the result myself on the machines listed above.