Potential crash due to parallel mod loading
embeddedt opened this issue ยท 0 comments
At the end of your FMLClientSetupEvent
you call ModColourManager.registerColourHandlers
. That function then registers color handlers to the BlockColors
and ItemColors
classes. The problem is that FMLClientSetupEvent
is called in parallel for multiple mods, while BlockColors
and ItemColors
are not thread-safe. This can very rarely lead to a crash when the data structures in these classes are corrupted by the concurrent access. To avoid this you should wrap the call using the enqueueWork
method provided on the event.
I ran into this on 1.16 but it probably affects most post-1.13 versions.
[18:44:05] [Worker-Main-2/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event FMLClientSetupEvent dispatch for modid mob_grinding_utils
java.lang.ArrayIndexOutOfBoundsException: Index 2048 out of bounds for length 1025
at it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap.rehash(Reference2ReferenceOpenHashMap.java:908) ~[fastutil-8.2.1.jar:?] {re:classloading}
at it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap.insert(Reference2ReferenceOpenHashMap.java:273) ~[fastutil-8.2.1.jar:?] {re:classloading}
at it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap.put(Reference2ReferenceOpenHashMap.java:281) ~[fastutil-8.2.1.jar:?] {re:classloading}
at net.minecraft.client.renderer.color.BlockColors.handler$zba000$preRegisterColor(BlockColors.java:531) ~[?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:rubidium.mixins.json:core.model.MixinBlockColors,pl:mixin:A,pl:runtimedistcleaner:A}
at net.minecraft.client.renderer.color.BlockColors.func_186722_a(BlockColors.java) ~[?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:rubidium.mixins.json:core.model.MixinBlockColors,pl:mixin:A,pl:runtimedistcleaner:A}
at mob_grinding_utils.ModColourManager.registerBlockColourHandlers(ModColourManager.java:39) ~[mob_grinding_utils:1.16.5-0.4.37] {re:classloading}
at mob_grinding_utils.ModColourManager.registerColourHandlers(ModColourManager.java:22) ~[mob_grinding_utils:1.16.5-0.4.37] {re:classloading}
at mob_grinding_utils.MobGrindingUtils.doClientStuff(MobGrindingUtils.java:194) ~[mob_grinding_utils:1.16.5-0.4.37] {re:classloading}
at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) ~[eventbus-4.0.0.jar:?] {}
at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239) ~[eventbus-4.0.0.jar:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {}
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}
at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:106) ~[forge:36.2] {re:classloading}
at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:107) ~[forge:?] {re:classloading}
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) [?:?] {}
at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728) [?:?] {}
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) [?:?] {}
at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) [?:?] {}
at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) [?:?] {re:computing_frames}
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) [?:?] {re:computing_frames}
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) [?:?] {}