BuildCraft|Core

BuildCraft|Core

7M Downloads

java.util.ConcurrentModificationException in EntityTracker

ictrobot opened this issue ยท 18 comments

commented

Hello,

I run a Minecraft Server for a few friends and recently we have been experiencing crashes every few hours. As I couldn't find anything about the issue online, I decided to fork forge and add logging code to the EntityTracker class (See here). Next time the server crashed, I had this output, which suggests Buildcraft's MapManager thread is causing the issue. Normally there is

18:07:08.102, DIM:0, net.minecraft.entity.EntityTracker@3ab9ae50, Server thread, updateTrackedEntities(), START
java.lang.RuntimeException: Debug
    at net.minecraft.entity.EntityTracker.write(EntityTracker.java:104)
    at net.minecraft.entity.EntityTracker.func_72788_a(EntityTracker.java:328)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:648)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

18:07:08.102, DIM:0, net.minecraft.entity.EntityTracker@3ab9ae50, Server thread, updateTrackedEntities(), END
java.lang.RuntimeException: Debug
    at net.minecraft.entity.EntityTracker.write(EntityTracker.java:104)
    at net.minecraft.entity.EntityTracker.func_72788_a(EntityTracker.java:358)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:648)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

Notice the updateTrackedEntities() START and updateTrackedEntities() END. But right at the end of the file there is

18:07:08.148, DIM:0, net.minecraft.entity.EntityTracker@3ab9ae50, Server thread, updateTrackedEntities(), START
java.lang.RuntimeException: Debug
    at net.minecraft.entity.EntityTracker.write(EntityTracker.java:104)
    at net.minecraft.entity.EntityTracker.func_72788_a(EntityTracker.java:328)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:648)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)

18:07:08.148, DIM:0, net.minecraft.entity.EntityTracker@3ab9ae50, Thread-13, addEntityToTracker(Entity, int, int, boolean)
ARGS: EntitySheep['Sheep'/77999, l='world', x=-1304.93, y=87.00, z=1450.49] 80 3 true 
java.lang.RuntimeException: Debug
    at net.minecraft.entity.EntityTracker.write(EntityTracker.java:104)
    at net.minecraft.entity.EntityTracker.func_72785_a(EntityTracker.java:249)
    at net.minecraft.entity.EntityTracker.func_72786_a(EntityTracker.java:213)
    at net.minecraft.world.WorldManager.func_72703_a(SourceFile:31)
    at net.minecraft.world.World.func_72923_a(World.java:1347)
    at net.minecraft.world.WorldServer.func_72923_a(WorldServer.java:844)
    at net.minecraft.world.World.func_72868_a(World.java:3304)
    at net.minecraft.world.chunk.Chunk.func_76631_c(Chunk.java:921)
    at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:46)
    at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:12)
    at net.minecraftforge.common.util.AsynchronousExecutor.skipQueue(AsynchronousExecutor.java:344)
    at net.minecraftforge.common.util.AsynchronousExecutor.getSkipQueue(AsynchronousExecutor.java:302)
    at net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:12)
    at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:126)
    at net.minecraft.world.gen.ChunkProviderServer.func_73158_c(ChunkProviderServer.java:101)
    at net.minecraft.world.gen.ChunkProviderServer.func_73154_d(ChunkProviderServer.java:199)
    at net.minecraft.world.World.func_72964_e(World.java:419)
    at buildcraft.robotics.map.MapWorld.updateChunk(MapWorld.java:191)
    at buildcraft.robotics.map.MapWorld.updateChunkInQueue(MapWorld.java:151)
    at buildcraft.robotics.map.MapManager.run(MapManager.java:84)
    at java.lang.Thread.run(Thread.java:745)

This suggests that the MapManager thread is causing modification to the EntityTracker while updateTrackedEntities() is running in the main thread, therefore causing the ConcurrentModificationException.

The actual crash report is available here, however note it says forge build 1500 because that is the custom value I set it to.

Thank you for your time

commented

I also experienced ConcurrentModificationExceptions when I upgraded from the latest BuildCraft 6.x to 7.0.7 on my server, though much more frequently. I don't remember the details and I don't still have the logs; a lot was happening that day, so I just rolled everything back and moved on. This sounds like the same thing, though.

Did anything start being threaded in BuildCraft that wasn't threaded before?

(Edit: also happened to remember the bug, wonder if it was fixed or reported yet, check that there wasn't a new release of BuildCraft, and hop over to the issue tracker just in time to watch your issue appear. Freaky.)

commented

Good point, this started happening after upgrading to BuildCraft 7

commented

@ictrobot - you figured out the CME! Wow! Thanks! I have been curious for months!

commented

Player also noticed this recently. This will be fixed.

commented
commented

Just trying

commented

Also throwing in on this issue being present on the BBQ pack with FML 1408, 1424 and 1448. I've had aprx 10 crashes today since updating to 7.0.6, all at seemingly random times with no apparent trigger, during times of world generation and times when there was no worldgen taking place. To troubleshoot the issue, I have removed DynMap and Fastcraft (other mods as well just to troubleshoot) to no avail. I had not gotten to the point of downgrading BC yet.

Sample pastebins here:

http://pastebin.com/CBneFpzN
http://pastebin.com/VFtyEDCu
http://pastebin.com/RY9ZmdxL

Updated to BC 7.0.6 with BC|Compat 7.0.5 just today when the crashes started.

Let me know if there is any way I can help.

commented

Server has been running for 5 minutes and so far has not crashed. I will comment again in a few hours.

commented

@ictrobot - Please comment again in about 30 minutes, if you could; the issue usually appears once every 10 and I really want to release before I go sleep.

commented

New issue

java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) ~[?:1.8.0_45]
    at java.util.HashMap$KeyIterator.next(HashMap.java:1453) ~[?:1.8.0_45]
    at buildcraft.robotics.map.MapManager.serverTickEnd(MapManager.java:110) ~[MapManager.class:?]
    at cpw.mods.fml.common.eventhandler.ASMEventHandler_722_MapManager_serverTickEnd_ServerTickEvent.invoke(.dynamic) ~[?:?]
    at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?]
    at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?]
    at cpw.mods.fml.common.FMLCommonHandler.onPostServerTick(FMLCommonHandler.java:247) ~[FMLCommonHandler.class:?]
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:590) ~[MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?]

Full crash report

This is now using normal forge again, version 10.13.4.1448

commented

Gah. I'll get back to this tomorrow. I need to sleep.

commented

It seems to work, however I have only tested it for 15 minutes as I have to get some sleep. Previously it has taken up to 20 hours for the server to crash, so this is by no means conclusive.

I will do more testing tommorow

commented

Just had one last check before going to bed, and it crashed.

java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) ~[?:1.8.0_45]
    at java.util.HashMap$KeyIterator.next(HashMap.java:1453) ~[?:1.8.0_45]
    at net.minecraft.entity.EntityTracker.func_72788_a(EntityTracker.java:269) ~[mn.class:?]
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:648) ~[MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334) ~[lt.class:?]
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) ~[MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?]

Full Crash Report

Again this was with normal forge, version 10.13.4.1448. However I am unsure what the cause of this is as I haven't run my special forge version yet.

commented

@ictrobot - fixed once and for all in 7.0.9 Stable, I hope.

commented

Just reproduced the most recent crash above with my version of forge that logs EntityTracker activity. See output.
Crash log here. This is with bc709j.jar linked above.

commented

@asiekierka - We've been 6 hours now without a crash on 7.0.9. I will update you in another 6 hours.

Thank you :)

commented

@asiekierka My server has been running for 8 hours so far without issue. Thank you for all your help :D