mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Fix concurrency issue in light engine (Vanilla bug)
Mojang implemented a cache like chunks have, but this cache is accessed by multiple threads and is totally not safe. So just remove it Fixes #3466 Also missed a pooled nibble release, so slid that in there too.
This commit is contained in:
parent
db127b6f9c
commit
6bff219f15
@ -57,7 +57,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
public void a(long i) {
|
public void a(long i) {
|
||||||
if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
|
if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
|
||||||
- this.data.queueUpdate(i, ((NibbleArray) this.data.getUpdating(i)).b()); // Paper - avoid copying light data
|
- this.data.queueUpdate(i, ((NibbleArray) this.data.getUpdating(i)).b()); // Paper - avoid copying light data
|
||||||
+ this.data.queueUpdate(i, new NibbleArray().markPoolSafe(this.data.getUpdating(i).getCloneIfSet())); // Paper - avoid copying light data - pool safe clone
|
+ NibbleArray updating = this.data.getUpdating(i); // Paper - pool nibbles
|
||||||
|
+ this.data.queueUpdate(i, new NibbleArray().markPoolSafe(updating.getCloneIfSet())); // Paper - avoid copying light data - pool safe clone
|
||||||
|
+ if (updating.cleaner != null) updating.cleaner.run(); // Paper
|
||||||
this.c();
|
this.c();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,16 +103,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -0,0 +0,0 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
public NibbleArray c(long i) {
|
||||||
|
+ // Paper start - remove cache - not thread safe
|
||||||
|
+ /*
|
||||||
|
if (this.d) {
|
||||||
|
for (int j = 0; j < 2; ++j) {
|
||||||
|
if (i == this.b[j]) {
|
||||||
|
return this.c[j];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
- }
|
||||||
|
+ }*/
|
||||||
|
+ // Paper end
|
||||||
|
|
||||||
- NibbleArray nibblearray = (NibbleArray) this.a.get(i);
|
- NibbleArray nibblearray = (NibbleArray) this.a.get(i);
|
||||||
+ NibbleArray nibblearray = (NibbleArray) (this.isVisible ? this.data.getVisibleAsync(i) : this.data.getUpdating(i)); // Paper - avoid copying light data
|
+ NibbleArray nibblearray = (NibbleArray) (this.isVisible ? this.data.getVisibleAsync(i) : this.data.getUpdating(i)); // Paper - avoid copying light data
|
||||||
|
|
||||||
|
+ // Paper start - remove cache - not thread safe
|
||||||
|
+ return nibblearray;
|
||||||
|
+ /*
|
||||||
if (nibblearray == null) {
|
if (nibblearray == null) {
|
||||||
return null;
|
return null;
|
||||||
|
} else {
|
||||||
@@ -0,0 +0,0 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
@@ -0,0 +0,0 @@ public abstract class LightEngineStorageArray<M extends LightEngineStorageArray<
|
||||||
|
}
|
||||||
|
|
||||||
|
return nibblearray;
|
||||||
|
- }
|
||||||
|
+ }*/
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public NibbleArray d(long i) {
|
public NibbleArray d(long i) {
|
||||||
@ -128,6 +148,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void c() {
|
public void c() {
|
||||||
|
+ /* // Paper - remove cache
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
this.b[i] = Long.MAX_VALUE;
|
||||||
|
this.c[i] = null;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ */
|
||||||
|
}
|
||||||
|
|
||||||
|
public void d() {
|
||||||
diff --git a/src/main/java/net/minecraft/server/LightEngineStorageBlock.java b/src/main/java/net/minecraft/server/LightEngineStorageBlock.java
|
diff --git a/src/main/java/net/minecraft/server/LightEngineStorageBlock.java b/src/main/java/net/minecraft/server/LightEngineStorageBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/LightEngineStorageBlock.java
|
--- a/src/main/java/net/minecraft/server/LightEngineStorageBlock.java
|
||||||
|
Loading…
Reference in New Issue
Block a user