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.
This commit is contained in:
Aikar 2020-06-09 23:01:47 -04:00
parent 3028a91f26
commit bfe5d554d3
2 changed files with 9 additions and 6 deletions

View File

@ -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<EntityPlayer> 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);

View File

@ -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