Skip to content

Commit cbf0d89

Browse files
committed
fix(macOS): destroy EGL context via EGL, not SDL_GL_DeleteContext (shutdown crash)
On macOS the Zink/KosmicKrisp bootstrap stores the EGL context in glContext (glContext = (SDL_GLContext)g_eglContext). DestroyWindowAndContext then passed it to SDL_GL_DeleteContext, which treats an EGL context as an SDL/native GL context and crashes on quit (SIGSEGV in SDL DispatchedDeleteContext -> CGlobalRendering::~CGlobalRendering). Call the existing DestroyEGLContext() on __APPLE__ instead. The game rendered fine; it only crashed during shutdown.
1 parent 59a9ded commit cbf0d89

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

rts/Rendering/GlobalRendering.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,18 @@ void CGlobalRendering::DestroyWindowAndContext() {
992992
SDL_DestroyWindow(sdlWindow);
993993

994994
#if !defined(HEADLESS)
995+
#if defined(__APPLE__)
996+
// On macOS, glContext holds the EGL context (set in InitGL via the Zink/
997+
// KosmicKrisp bootstrap), not an SDL/native GL context. Passing it to
998+
// SDL_GL_DeleteContext treats an EGL context as an SDL one and crashes on
999+
// shutdown (DispatchedDeleteContext dereferences a bad pointer). Tear it
1000+
// down through EGL instead.
1001+
DestroyEGLContext();
1002+
#else
9951003
if (glContext)
9961004
SDL_GL_DeleteContext(glContext);
9971005
#endif
1006+
#endif
9981007

9991008
sdlWindow = nullptr;
10001009
glContext = nullptr;

0 commit comments

Comments
 (0)