lithium-fabric icon indicating copy to clipboard operation
lithium-fabric copied to clipboard

Client crash caused by ConcurrentModificationException

Open Asayu233 opened this issue 6 months ago • 4 comments

Version

lithium-fabric-mc1.21.4-0.15.3

Reproduction Steps

I can't reproduce it in a fixed way, it happens randomly. Maybe it happens more easily when there are more entities in the world...

Crash Report File

crash-2025-05-06_03.59.00-client.txt

Minecraft Save

It may happen in any save.

Additional Information

I checked the call chain and found no unusual modifications to the collection. I'm guessing it might be related to thread contention? I'm not even sure if this is an issue with Lithium mod or Minecraft itself...

at net.minecraft.world.level.entity.EntitySection.getEntities at ... at net.caffeinemc.mods.lithium.mixin.entity.fast_retrieval.EntitySectionStorageMixin.forEachInBox at ... at net.minecraft.world.level.EntityGetter.getEntities at fi.dy.masa.minihud.util.RayTraceUtils.getRayTraceFromEntity

Asayu233 avatar May 05 '25 21:05 Asayu233

There might be some incompatibility, have to check whether vanilla's section iteration is safe against modification

2No2Name avatar May 05 '25 21:05 2No2Name

https://github.com/CaffeineMC/lithium/blob/develop/lithium-mixin-config.md

Adding the line mixin.entity.fast_retrieval=false to the lithium.properties file in the config folder might help

2No2Name avatar May 05 '25 21:05 2No2Name

https://github.com/CaffeineMC/lithium/blob/develop/lithium-mixin-config.md

Adding the line mixin.entity.fast_retrieval=false to the lithium.properties file in the config folder might help

I tried this just now and the crash happened again

java.util.ConcurrentModificationException
	at [email protected]/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1096)
	at [email protected]/java.util.ArrayList$Itr.next(ArrayList.java:1050)
	at knot//net.minecraft.world.level.entity.EntitySection.getEntities(EntitySection.java:33)
	at knot//net.minecraft.world.level.entity.EntitySectionStorage.lambda$getEntities$1(EntitySectionStorage.java:123)
	at knot//net.minecraft.world.level.entity.EntitySectionStorage.forEachAccessibleNonEmptySection(EntitySectionStorage.java:66)
	at knot//net.minecraft.world.level.entity.EntitySectionStorage.getEntities(EntitySectionStorage.java:123)
	at knot//net.minecraft.world.level.entity.LevelEntityGetterAdapter.get(LevelEntityGetterAdapter.java:43)
	at knot//net.minecraft.world.level.Level.getEntities(Level.java:677)
	at knot//net.minecraft.world.level.EntityGetter.getEntities(EntityGetter.java:30)
	at knot//fi.dy.masa.minihud.util.RayTraceUtils.getRayTraceFromEntity(RayTraceUtils.java:46)
	at knot//fi.dy.masa.minihud.util.RayTraceUtils.getRayTraceFromEntity(RayTraceUtils.java:26)
	at knot//fi.dy.masa.minihud.renderer.InventoryOverlayHandler.getTargetInventory(InventoryOverlayHandler.java:164)
	at knot//fi.dy.masa.minihud.renderer.InventoryOverlayHandler.getRenderContext(InventoryOverlayHandler.java:121)
	at knot//fi.dy.masa.minihud.event.RenderHandler.onRenderGameOverlayPostAdvanced(RenderHandler.java:206)
	at knot//fi.dy.masa.malilib.event.RenderEventHandler.onRenderGameOverlayPost(RenderEventHandler.java:108)
	at knot//net.minecraft.client.gui.Gui.handler$dio000$malilib$onGameOverlayPost(Gui.java:5555)
	at knot//net.minecraft.client.gui.Gui.render$mixinextras$wrapped$123(Gui.java:235)
	at knot//net.minecraft.client.gui.Gui.mixinextras$bridge$method_1753$mixinextras$wrapped$123$124(Gui.java)
	at knot//net.minecraft.client.gui.Gui.wrapMethod$clb000$iris$handleHudHidingScreens(Gui.java:5064)
	at knot//net.minecraft.client.gui.Gui.render(Gui.java)
	at knot//net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:533)
	at knot//net.minecraft.client.Minecraft.runTick(Minecraft.java:1341)
	at knot//net.minecraft.client.Minecraft.run(Minecraft.java:922)
	at knot//net.minecraft.client.main.Main.main(Main.java:267)
	at app//net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:480)
	at app//net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at app//net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)

Asayu233 avatar May 05 '25 22:05 Asayu233

It looks like minihud just calls a vanilla function on the client main thread. I think this is more like a Minecraft bug? Or maybe some mods made unsafe collection modifications in other threads...

Asayu233 avatar May 05 '25 22:05 Asayu233