2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Thu, 18 Feb 2021 20:23:28 +0000
Subject: [PATCH] misc debugging dumps
diff --git a/src/main/java/io/papermc/paper/util/TraceUtil.java b/src/main/java/io/papermc/paper/util/TraceUtil.java
new file mode 100644
2024-04-25 06:38:28 +02:00
index 0000000000000000000000000000000000000000..479bb92d159f33c54c2d9c39d8a63aa9e74d95b9
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/util/TraceUtil.java
2024-04-25 06:38:28 +02:00
@@ -0,0 +1,25 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.util;
+
+import org.bukkit.Bukkit;
+
+public final class TraceUtil {
+
+ public static void dumpTraceForThread(Thread thread, String reason) {
+ Bukkit.getLogger().warning(thread.getName() + ": " + reason);
2024-04-25 06:38:28 +02:00
+ StackTraceElement[] trace = StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace());
2021-06-11 14:02:28 +02:00
+ for (StackTraceElement traceElement : trace) {
+ Bukkit.getLogger().warning("\tat " + traceElement);
+ }
+ }
+
+ public static void dumpTraceForThread(String reason) {
2024-04-25 06:38:28 +02:00
+ final Throwable thr = new Throwable(reason);
+ StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(thr);
+ thr.printStackTrace();
+ }
+
+ public static void printStackTrace(Throwable thr) {
+ StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(thr);
+ thr.printStackTrace();
2021-06-11 14:02:28 +02:00
+ }
+}
2024-01-11 17:15:17 +01:00
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
2024-04-27 08:17:58 +02:00
index f15c388434a0a501f86868de35cc138756975027..5044a7dc120c8b040ee23365d2bf97e6180e3ee4 100644
2024-01-11 17:15:17 +01:00
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
2024-04-27 08:17:58 +02:00
@@ -342,7 +342,7 @@ public class Commands {
2024-01-11 17:15:17 +01:00
} catch (Exception exception) {
MutableComponent ichatmutablecomponent = Component.literal(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
- if (Commands.LOGGER.isDebugEnabled()) {
2024-01-21 12:11:43 +01:00
+ if (commandlistenerwrapper.getServer().isDebugging() || Commands.LOGGER.isDebugEnabled()) { // Paper - Debugging
2024-01-11 17:15:17 +01:00
Commands.LOGGER.error("Command exception: /{}", s, exception);
StackTraceElement[] astacktraceelement = exception.getStackTrace();
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2024-06-13 16:45:27 +02:00
index 6e31678d1b49584208b7c0ed1f6cfd394f597362..92cb9a0a479f3dc1c78eda42191d020106d059dd 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2024-05-16 02:06:59 +02:00
@@ -909,6 +909,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2024-01-23 12:06:27 +01:00
2021-06-11 14:02:28 +02:00
// CraftBukkit start
private boolean hasStopped = false;
2024-01-21 12:11:43 +01:00
+ private boolean hasLoggedStop = false; // Paper - Debugging
2021-06-11 14:02:28 +02:00
private final Object stopLock = new Object();
public final boolean hasStopped() {
2021-06-15 04:59:31 +02:00
synchronized (this.stopLock) {
2024-05-16 02:06:59 +02:00
@@ -923,6 +924,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2021-06-15 04:59:31 +02:00
if (this.hasStopped) return;
this.hasStopped = true;
2021-06-11 14:02:28 +02:00
}
2024-01-21 12:11:43 +01:00
+ if (!hasLoggedStop && isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread("Server stopped"); // Paper - Debugging
2024-01-23 12:06:27 +01:00
// CraftBukkit end
if (this.metricsRecorder.isRecording()) {
this.cancelRecordingMetrics();
2024-05-16 02:06:59 +02:00
@@ -1027,6 +1029,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2021-06-15 04:59:31 +02:00
}
2022-12-07 21:16:54 +01:00
public void safeShutdown(boolean waitForShutdown, boolean isRestarting) {
2021-06-11 14:02:28 +02:00
this.isRestarting = isRestarting;
2024-01-21 12:11:43 +01:00
+ this.hasLoggedStop = true; // Paper - Debugging
+ if (isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread("Server stopped"); // Paper - Debugging
2021-06-15 04:59:31 +02:00
// Paper end
this.running = false;
2022-12-07 21:16:54 +01:00
if (waitForShutdown) {
2023-09-22 06:05:18 +02:00
diff --git a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
2024-04-25 23:21:18 +02:00
index 970d1ddf0a014b47b0ac97440489706137324991..e4086bea596e5f5d71491e0b7ad650d76939b8f9 100644
2023-09-22 06:05:18 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
2024-04-25 23:21:18 +02:00
@@ -62,6 +62,10 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis
2024-02-23 14:54:52 +01:00
@Override
public void onDisconnect(Component reason) {
+ // Paper start - Debugging
+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) {
+ ServerConfigurationPacketListenerImpl.LOGGER.info("{} lost connection: {}, while in configuration phase {}", this.gameProfile, reason.getString(), currentTask != null ? currentTask.type().id() : "null");
+ } else // Paper end
ServerConfigurationPacketListenerImpl.LOGGER.info("{} lost connection: {}", this.gameProfile, reason.getString());
super.onDisconnect(reason);
}
2024-04-25 23:21:18 +02:00
@@ -149,6 +153,11 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis
2024-04-24 08:44:48 +02:00
playerlist.placeNewPlayer(this.connection, entityplayer, this.createCookie(this.clientInformation));
2023-09-22 06:05:18 +02:00
} catch (Exception exception) {
ServerConfigurationPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception);
2024-01-21 12:11:43 +01:00
+ // Paper start - Debugging
2023-09-22 06:05:18 +02:00
+ if (MinecraftServer.getServer().isDebugging()) {
+ exception.printStackTrace();
+ }
2024-01-21 12:11:43 +01:00
+ // Paper end - Debugging
2023-09-22 06:05:18 +02:00
this.connection.send(new ClientboundDisconnectPacket(ServerConfigurationPacketListenerImpl.DISCONNECT_REASON_INVALID_DATA));
this.connection.disconnect(ServerConfigurationPacketListenerImpl.DISCONNECT_REASON_INVALID_DATA);
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2024-06-13 16:45:27 +02:00
index af99292c4461819c4c7d304134f3f3ffb88c175d..9cc6f2ae2f0ae71d550f0da5f81412a434b0bdf7 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2024-06-13 16:45:27 +02:00
@@ -1036,6 +1036,7 @@ public final class CraftServer implements Server {
2021-09-11 19:27:48 +02:00
plugin.getDescription().getFullName(),
2021-06-11 14:02:28 +02:00
"This plugin is not properly shutting down its async tasks when it is being reloaded. This may cause conflicts with the newly loaded version of the plugin"
));
2024-01-21 12:11:43 +01:00
+ if (console.isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread(worker.getThread(), "still running"); // Paper - Debugging
2021-06-11 14:02:28 +02:00
}
2023-02-23 18:58:50 +01:00
io.papermc.paper.plugin.PluginInitializerManager.reload(this.console); // Paper
2021-06-15 04:59:31 +02:00
this.loadPlugins();