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-04-27 01:17:13 +02:00
index b260b197bc254d22a9fd0f1c2dd799930489c8f7..c0d467cc65c208aa1166a24dec753b1e2b3d995b 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-04-24 08:44:48 +02:00
@@ -912,6 +912,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-04-24 08:44:48 +02:00
@@ -926,6 +927,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-04-24 08:44:48 +02:00
@@ -1030,6 +1032,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-04-27 08:17:58 +02:00
index 2431f687fb0ad6c904448f47fad926b136cba815..c62936e7070d794aeac7e5175757aa045a6afcae 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-04-27 08:17:58 +02:00
@@ -1017,6 +1017,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();