Skip to content

SDL_GL_SwapWindow blocks main thread after window close on Windows (zombie process) #12221

Description

@DeterMination-Wind

Problem

On Windows (reproduced with JDK 25.0.3), closing the Mindustry window leaves a zombie javaw.exe process that never exits.

Root Cause

After the SDL window is closed, the main thread gets stuck in SDL_GL_SwapWindow (native call) and never returns. Since DesktopLauncher.main() has no System.exit(0) after SdlApplication returns, the JVM waits indefinitely for the main thread.

jstack of the zombie process:

"main" #3 prio=5 os_prio=0 cpu=53015.62ms elapsed=107.08s tid=... runnable
   java.lang.Thread.State: RUNNABLE
        at arc.backend.sdl.jni.SDL.SDL_GL_SwapWindow(Native Method)
        at arc.backend.sdl.SdlApplication.loop(SdlApplication.java:218)
        at arc.backend.sdl.SdlApplication.<init>(SdlApplication.java:58)
        at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:53)

The window is gone (not visible), but the native OpenGL swap buffer call never completes. All other threads are daemon threads — the main thread is the only blocker.

Environment

  • OS: Windows 10/11
  • JDK: Java 25.0.3 (Oracle)
  • Mindustry: BE-20260613 (SDL backend)
  • Reproduced by launching via double-click on .jar

Proposed Fix

Add System.exit(0) at the end of DesktopLauncher.main() after the SdlApplication constructor returns. This is the standard approach used by libGDX's LWJGL3 backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions