Fuzss / diagonalblocks

The core library behind the diagonal blocks mod series!
Mozilla Public License 2.0
10 stars 5 forks source link

[Bug]: Runtime resource pack is not thread-safe #38

Closed embeddedt closed 1 year ago

embeddedt commented 1 year ago

Mod Loader (Required)

Forge

Minecraft Version (Required)

1.16.5

Mod Version (Required)

1.1.1

Notes (Required)

The following ConcurrentModificationException can be thrown if the runtime resource pack is accessed by multiple threads concurrently:

Caused by: java.util.ConcurrentModificationException
    at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1585) ~[?:1.8.0_372]
    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742) ~[?:1.8.0_372]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_372]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_372]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_372]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_372]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_372]
    at fuzs.diagonalfences.resources.RuntimeResourcePack.getAllResourceLocations(RuntimeResourcePack.java:156) ~[diagonalfences:1.1.1]
    at fuzs.diagonalfences.resources.RuntimeResourcePack.func_195764_b(RuntimeResourcePack.java:99) ~[diagonalfences:1.1.1]
    at net.minecraft.resources.FallbackResourceManager.func_199004_b(FallbackResourceManager.java:102) ~[?:?]
    at net.minecraft.resources.SimpleReloadableResourceManager.func_199004_b(SimpleReloadableResourceManager.java:75) ~[?:?]

As far as I know, Minecraft resource packs are expected to be thread-safe, as there are multiple threads that load resources at once.

latest.log (Optional)

No response

Fuzss commented 1 year ago

I saw you made a fix for this in ModernFix, is that enough?

I'd rather not push another update to 1.16 to be honest, it's quite tricky to even get a workspace setup as I switched to an ARM Mac and older ForgeGradle setups really don't work well if at all on that.

embeddedt commented 1 year ago

I didn't see the exception in a while, so probably; if it happens again I'll just apply a mixin to RuntimeResourcePack directly to fix it.