From 1487ee284ea7fdb6bc95a794a6cdd084b9b0b668 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 24 Feb 2021 18:45:21 +0000 Subject: [PATCH] Don't grab the threads stacktrace when dumping same thread For some reason, this doesn't always seem to capture all states of shutdown, either the logger is just being fun, or, potentially, the thread is already marked as dead when we're getting called so the trace is not generated through the method on Thread --- Spigot-Server-Patches/misc-debugging-dumps.patch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Spigot-Server-Patches/misc-debugging-dumps.patch b/Spigot-Server-Patches/misc-debugging-dumps.patch index bcdfc4e4e..3ea1fb500 100644 --- a/Spigot-Server-Patches/misc-debugging-dumps.patch +++ b/Spigot-Server-Patches/misc-debugging-dumps.patch @@ -23,6 +23,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Bukkit.getLogger().warning("\tat " + traceElement); + } + } ++ ++ public static void dumpTraceForThread(String reason) { ++ new Throwable(reason).printStackTrace(); ++ } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -48,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (hasStopped) return; hasStopped = true; } -+ if (!hasLoggedStop && isDebugging()) TraceUtil.dumpTraceForThread(this.getThread(), "Server stopped"); // Paper ++ if (!hasLoggedStop && isDebugging()) TraceUtil.dumpTraceForThread("Server stopped"); // Paper // Paper start - kill main thread, and kill it hard shutdownThread = Thread.currentThread(); org.spigotmc.WatchdogThread.doStop(); // Paper @@ -57,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.isRunning = false; this.isRestarting = isRestarting; + this.hasLoggedStop = true; // Paper -+ if (isDebugging()) TraceUtil.dumpTraceForThread(this.getThread(), "Server stopped"); // Paper ++ if (isDebugging()) TraceUtil.dumpTraceForThread("Server stopped"); // Paper if (flag) { try { this.serverThread.join();