From bfe5d554d35134a04d3be7baf68fabf74347c65f Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 9 Jun 2020 23:01:47 -0400 Subject: [PATCH] Improve ChunkMapDistance.b crash fix to clean up properly There is some vanilla level bug where this tracking state appears to get messed up and player doesn't exists in chunk its trying to untrack. We returned early to prevent crashing, but I suspect if there was a level being tracked for the chunk, it got leaked due to the early return. So going to ensure we clean up the level tracker when this state occurs. This may help with any leaked chunk issues. --- ...ash-if-player-is-attempted-to-be-removed-fro.patch | 11 +++++++---- ...Optimize-isOutsideRange-to-use-distance-maps.patch | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch b/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch index 4b0417ff2e..b79282d73a 100644 --- a/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch +++ b/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch @@ -11,10 +11,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/ChunkMapDistance.java +++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java @@ -0,0 +0,0 @@ public abstract class ChunkMapDistance { - public void b(SectionPosition sectionposition, EntityPlayer entityplayer) { long i = sectionposition.u().pair(); ObjectSet objectset = (ObjectSet) this.c.get(i); -+ if (objectset == null) return; // Paper - mitigate weird state mismatch that this chunk isn't tracked. - objectset.remove(entityplayer); - if (objectset.isEmpty()) { +- objectset.remove(entityplayer); +- if (objectset.isEmpty()) { ++ if (objectset != null) objectset.remove(entityplayer); // Paper - some state corruption happens here, don't crash, clean up gracefully. ++ if (objectset == null || objectset.isEmpty()) { // Paper + this.c.remove(i); + this.f.b(i, Integer.MAX_VALUE, false); + this.g.b(i, Integer.MAX_VALUE, false); diff --git a/Spigot-Server-Patches/Optimize-isOutsideRange-to-use-distance-maps.patch b/Spigot-Server-Patches/Optimize-isOutsideRange-to-use-distance-maps.patch index 4e2587f5b0..44fdb9491f 100644 --- a/Spigot-Server-Patches/Optimize-isOutsideRange-to-use-distance-maps.patch +++ b/Spigot-Server-Patches/Optimize-isOutsideRange-to-use-distance-maps.patch @@ -46,8 +46,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public abstract class ChunkMapDistance { - objectset.remove(entityplayer); - if (objectset.isEmpty()) { + if (objectset != null) objectset.remove(entityplayer); // Paper - some state corruption happens here, don't crash, clean up gracefully. + if (objectset == null || objectset.isEmpty()) { // Paper this.c.remove(i); - this.f.b(i, Integer.MAX_VALUE, false); + //this.f.b(i, Integer.MAX_VALUE, false); // Paper - no longer used