From a93388c2ad1aed7757cd441628e6a298f1c7bea6 Mon Sep 17 00:00:00 2001 From: David 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/server/World.java b/src/main/java/net/minecraft/server/World.java index 6ad9a9b6..8a9b1b65 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -87,6 +87,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot public final SpigotTimings.WorldTimingsHandler timings; // Spigot + public static BlockPosition lastPhysicsProblem; // Spigot public CraftWorld getWorld() { return this.world; @@ -300,7 +301,13 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose // 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); + // Spigot start + try { + notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i); + } catch (StackOverflowError ex) { + lastPhysicsProblem = new BlockPosition(blockposition); + } + // Spigot end } // CraftBukkit end @@ -457,6 +464,10 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose } // CraftBukkit end iblockdata.doPhysics(this, blockposition, block, blockposition1, false); + // Spigot Start + } catch (StackOverflowError ex) { + lastPhysicsProblem = new BlockPosition(blockposition); + // Spigot End } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated"); diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java index df33e151..27297204 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -70,6 +70,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.server.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.server.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.20.1