Skip to content

Force System.exit(0) after SdlApplication returns to prevent zombie processes#12222

Open
DeterMination-Wind wants to merge 1 commit into
Anuken:masterfrom
DeterMination-Wind:fix-zombie
Open

Force System.exit(0) after SdlApplication returns to prevent zombie processes#12222
DeterMination-Wind wants to merge 1 commit into
Anuken:masterfrom
DeterMination-Wind:fix-zombie

Conversation

@DeterMination-Wind

Copy link
Copy Markdown

Summary

  • Add System.exit(0) at the end of DesktopLauncher.main() to force JVM exit after SdlApplication returns

Problem

On Windows, closing the Mindustry window can leave a zombie javaw.exe process. The main thread gets stuck in SDL_GL_SwapWindow (native) and never returns. All other threads are daemon threads, so the JVM waits indefinitely.

jstack of zombie:

"main" #3 prio=5 ... 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)

Fix

System.exit(0) after the try-catch block in main(). This is the standard approach used by libGDX's LWJGL3 backend. The SdlApplication constructor handles all cleanup (dispose, SDL_DestroyWindow, SDL_Quit) before returning, so System.exit(0) is safe here.

Fixes #12221

…rocesses on Windows

On Windows, SDL_GL_SwapWindow can block indefinitely after the window is
closed, preventing the main thread from returning. Since all other threads
are daemon threads, the JVM cannot exit naturally. Adding System.exit(0)
ensures the process terminates regardless of native thread state.

Fixes Anuken#12221
@TOWUK

TOWUK commented Jun 14, 2026

Copy link
Copy Markdown

I agree, there is such a thing, sometimes I manually closed java(w).exe after the game

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.

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

2 participants