From 2ecc06a8fbc02cea9f90eef9ce8e40b5d9638316 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 27 Dec 2021 04:11:21 -0800 Subject: [PATCH] Defensively copy chunk data in upgradeChunkTag The data provided is always from the regionfile thread, which does not copy the data out. So if two separate calls need the data, then there's going to be a problem. --- patches/server/Asynchronous-chunk-IO-and-loading.patch | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/patches/server/Asynchronous-chunk-IO-and-loading.patch b/patches/server/Asynchronous-chunk-IO-and-loading.patch index 3ee7d3b94e..ff282ad244 100644 --- a/patches/server/Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/Asynchronous-chunk-IO-and-loading.patch @@ -3219,6 +3219,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CompoundTag level = nbt.getCompound("Level"); if (level.getBoolean("TerrainPopulated")) { @@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { + + public CompoundTag upgradeChunkTag(ResourceKey resourcekey, Supplier supplier, CompoundTag nbttagcompound, Optional>> optional, ChunkPos pos, @Nullable LevelAccessor generatoraccess) throws IOException { + // CraftBukkit end ++ nbttagcompound = nbttagcompound.copy(); // Paper - defensive copy, another thread might modify this + int i = ChunkStorage.getVersion(nbttagcompound); + + // CraftBukkit start +@@ -0,0 +0,0 @@ public class ChunkStorage implements AutoCloseable { if (i < 1493) { nbttagcompound = NbtUtils.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493); if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {