Skip to content

Game loop crashes (ConcurrentModificationException) when a world-spawn item is picked up #992

@HarleyGilpin

Description

@HarleyGilpin

GameLoop crash: ConcurrentModificationException in FloorItems.run()

FloorItems.run() (FloorItems.kt:39) throws a ConcurrentModificationException, killing the tick loop until restart.

java.util.ConcurrentModificationException
    at world.gregs.voidps.engine.entity.item.floor.FloorItems.run(FloorItems.kt:39)
    at world.gregs.voidps.engine.GameLoop.tick(GameLoop.kt:44)

Root cause

run() iterates removeQueue with a for-each loop and fires Despawn.floorItem(item) per entry. The only registered handler, FloorItemRespawn (FloorItemRespawn.kt:11-16), calls FloorItems.add(...). When the target tile is at the 128-item cap, that add cascades display()full()remove(min), which appends to the removeQueue we're still iterating. The iterator detects the comodification and throws.

The same shape exists on addQueue (line 43) for any future floorItemSpawn handler that calls add/remove.

Repro: a tile with ~128 items plus a nearby world-spawn item picked up on the same tick. The despawn handler re-adds, the full-tile path evicts, CME fires.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions