Skip to content

Fix crash on exit after textures were created - #64

Merged
Flamefire merged 1 commit into
Return-To-The-Roots:masterfrom
littleant:fix-texture-cache-exit
Nov 18, 2026
Merged

Flamefire merged 1 commit into
Return-To-The-Roots:masterfrom
littleant:fix-texture-cache-exit

Conversation

@littleant

Copy link
Copy Markdown
Contributor

On Wayland/EGL, s25edit crashes on exit.

Some textures outlive the GL context: the static cache in getBmpTexture() is destroyed after SDL_Quit(), and the Texture members of CGame after ~CGame() has deleted the context. Their destructors still call glDeleteTextures().

Calling GL without a context is invalid on every platform. On Wayland/EGL it crashes because SDL has already unloaded the GL library at that point, so the call jumps into unmapped memory. On X11 and Windows the library apparently stays loaded, so the call goes unnoticed.

The fix only calls glDeleteTextures() while a GL context is current. This doesn't leak anything, because deleting the context already freed all of its textures.

The texture cache in getBmpTexture() is function-static and destroyed
after CGame deleted the GL context and SDL_Quit() ran. On Wayland/EGL
SDL has unloaded the GL library by then, so glDeleteTextures() jumps
into unmapped memory.

Only delete textures while a GL context is current. Textures that
outlive the context were already freed with it.
@Flamefire
Flamefire merged commit 1f1dab9 into Return-To-The-Roots:master Nov 18, 2026
1 of 6 checks passed
@littleant
littleant deleted the fix-texture-cache-exit branch November 19, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants