Skip to content

Fix thread leak hanging shutdown on 26.2#2975

Draft
TauCu wants to merge 1 commit into
EngineHub:version/7.4.xfrom
TauCu:fix/sessionmgr_thread_leak
Draft

Fix thread leak hanging shutdown on 26.2#2975
TauCu wants to merge 1 commit into
EngineHub:version/7.4.xfrom
TauCu:fix/sessionmgr_thread_leak

Conversation

@TauCu

@TauCu TauCu commented Jun 20, 2026

Copy link
Copy Markdown

Since 26.2, the client (and possibly server?) waits for threads to exit before closing. Crashing after a short time.
This pull fixes a bug where SessionManager didn't properly shut down.

The game crashed: client shutdown from post-main
Error: java.lang.Error: Watchdog (Client shutdown from post-main)

Cause:

  1. SessionManager is initialized at client start but only shutdown at server shutdown. If the client never opens a world, SessionManager#unload is never called.
  2. SessionManager#unload does not shutdown the executor, causing the client to time out and crash when waiting for it to exit anyway.

Fixes:

  • Move SessionManager to PlatformManager and make it use platform ready/unready events.
  • Fix SessionManager#unload canceling timer and no longer auto-saving after quitting a world.
  • Remove timer and use a single ScheduledExecutorService with a single virtual thread.
  • Make sure executor shuts down on SessionManager#unload

Draft reason:
I'm making this as a draft for now as I'm not entirely sure what consequences of making the session manager dependent on Ready/Unready event are.
I smoketested it on all platforms but that doesn't really say much.
Could someone with some knowledge of when SessionManager is supposed to be available chime in?

The only other thing I want some insight on was the effects of ScheduledExecutorService using an unbounded DelayedWorkQueue and the original used a bounded-queue of 5. Unless I'm missing something I don't think this will cause issues?

Move Session Manager to PlatformManager and shut it down with unready event.
Fix SessionManager#unload canceling timer, which prevents automatic saving of sessions after quitting a singleplayer world once.
@me4502

me4502 commented Jun 20, 2026

Copy link
Copy Markdown
Member

I'm a bit confused by this PR, is this specifically an issue on a certain platform? I've been using Fabric with WorldEdit installed while joining a server to test the Bukkit version of WorldEdit on 26.2 and never hit this issue, and from a quick test of just launching the game in both NF & Fabric to the menu and closing it I cannot reproduce any issues.

Can you please elaborate on what about 26.2 has caused this problem?

@TauCu

TauCu commented Jun 20, 2026

Copy link
Copy Markdown
Author

Are you using the normal launcher? The worldedit-fabric:run_client config also seems to do it.
I'm running Windows 10 LTSC, builtin JRE for the launcher, Temurin-25.0.3+9 for Intellij/Environment.

This is the crash: https://pastebin.com/9kgejvG0
This is a video of the crash: enc.webm

When using fix/sessionmgr_thread_leak branch there is no crash.

I also did some more testing and it seems the executor service doesn't seem to cause a crash, but the timer is. Either way, they should be shutdown cleanly.

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