Skip to content

Do not report halted regions in the watchdog - #515

Open
lewisgibson wants to merge 2 commits into
PaperMC:ver/26.2.xfrom
lewisgibson:watchdog-halted-regions
Open

lewisgibson wants to merge 2 commits into
PaperMC:ver/26.2.xfrom
lewisgibson:watchdog-halted-regions

Conversation

@lewisgibson

@lewisgibson lewisgibson commented Oct 1, 2026 •

Copy link
Copy Markdown

When the server stops, the region scheduler halts its threads, and a tick that was running on one of them can still be registered with FoliaWatchdogThread. Once the tick is older than five seconds the watchdog prints "has not responded" and calls WatchdogThread#dumpThread with the result of ThreadMXBean#getThreadInfo, which is null for a thread that has exited. That throws a NullPointerException and the Folia Watchdog Thread dies.

The ThreadInfo is now fetched before anything is printed and the tick is skipped if it is null. The change is in 0008-Add-watchdog-thread.patch, which owns the file.

I could not make a real stop hit this, the window is a few milliseconds. To check the code path I used a small test plugin that registers a tick that started 10 seconds ago on a thread that has already exited, which is the state a halted region leaves behind. On an unpatched build the watchdog thread dies with NullPointerException: Cannot invoke "java.lang.management.ThreadInfo.getThreadName()" because "thread" is null. With this change nothing is printed and the watchdog thread is still alive 4 seconds later.

This also happens on a normal stop with an unmodified build. From official Folia 26.2 build 7 (26.2-7-14b7fee), after the scheduler had already halted and while the server was still shutting down, so hasStopped() was still false:

[11:35:36 INFO]: [RegionShutdownThread] Scheduler halted
[11:35:36 INFO]: Stopping server
[11:35:36 ERROR]: [io.papermc.paper.threadedregions.FoliaWatchdogThread] Tick region located in world 'smokeworld' around chunk '[5, -3]' has not responded in 5.130362653s:
[11:35:37 INFO]: [RegionShutdownThread] Halting chunk systems...
[11:35:37 ERROR]: [io.papermc.paper.threadedregions.FoliaWatchdogThread] Uncaught exception in thread 'Folia Watchdog Thread'
java.lang.NullPointerException: Cannot invoke "java.lang.management.ThreadInfo.getThreadName()" because "thread" is null
	at org.spigotmc.WatchdogThread.dumpThread(WatchdogThread.java:162) ~[folia-26.2.jar:26.2-7-14b7fee]
	at io.papermc.paper.threadedregions.FoliaWatchdogThread.run(FoliaWatchdogThread.java:85) ~[folia-26.2.jar:26.2-7-14b7fee]

This was done with AI (Claude Opus 5.5 and GPT Astra, high effort). I've reviewed it and tested it myself.

The watchdog dereferenced the result of getThreadInfo, which is null once a halted region thread has exited. See the patch for details.
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.

1 participant