0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/spigot.git synced 2024-11-21 20:56:14 +00:00
spigot/CraftBukkit-Patches/0045-Prevent-NoClassDefError-crash-and-notify-on-crash.patch
2024-10-23 02:15:00 +11:00

70 lines
3.9 KiB
Diff

From 37266fdb905396848fb9b1f5324ad4f014be6abd Mon Sep 17 00:00:00 2001
From: David <dmck2b@gmail.com>
Date: Mon, 21 Apr 2014 12:43:08 +0100
Subject: [PATCH] Prevent NoClassDefError crash and notify on crash
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
index c4507a388c..a9dc7b9f1d 100644
--- a/src/main/java/net/minecraft/world/level/World.java
+++ b/src/main/java/net/minecraft/world/level/World.java
@@ -159,6 +159,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+ public static BlockPosition lastPhysicsProblem; // Spigot
public CraftWorld getWorld() {
return this.world;
@@ -378,7 +379,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
// CraftBukkit start
if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
// Modularize client and physic updates
- notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i, j);
+ // Spigot start
+ try {
+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i, j);
+ } catch (StackOverflowError ex) {
+ lastPhysicsProblem = new BlockPosition(blockposition);
+ }
+ // Spigot end
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
index 68dfd314c0..f526e8188a 100644
--- a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -69,6 +69,10 @@ public interface NeighborUpdater {
}
// CraftBukkit end
iblockdata.handleNeighborChanged(world, blockposition, block, orientation, flag);
+ // Spigot Start
+ } catch (StackOverflowError ex) {
+ world.lastPhysicsProblem = new BlockPosition(blockposition);
+ // Spigot End
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Block being updated");
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index 4734d4ae83..b4eeeb0d00 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -74,6 +74,13 @@ public class WatchdogThread extends Thread
log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
log.log( Level.SEVERE, "Spigot version: " + Bukkit.getServer().getVersion() );
//
+ if ( net.minecraft.world.level.World.lastPhysicsProblem != null )
+ {
+ log.log( Level.SEVERE, "------------------------------" );
+ log.log( Level.SEVERE, "During the run of the server, a physics stackoverflow was supressed" );
+ log.log( Level.SEVERE, "near " + net.minecraft.world.level.World.lastPhysicsProblem );
+ }
+ //
log.log( Level.SEVERE, "------------------------------" );
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Spigot!):" );
dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
--
2.47.0