mojira.dev

Thomas

Assigned

No issues.

Comments

Can confirm, affects Minecraft 26.2. Did some digging:

Conditions:

  • One or more worlds with the same seed

  • Generating village jigsaw structures at the same moment

  • On different worldgen worker threads

  • Shortly after the server/world has started.

The template objects are shared by every world, so two workers placing the same village piece for the first time can both enter Palette.blocks -> HashMap.computeIfAbsent on the same cache. Once an entry exists, later reads are safe, (which is why it only shows up early and rarely).

Reproduction:

Two threads call blocks (or getJigsaws) on one freshly loaded StructureTemplate for two different block types at the same time, over a few dozen rounds. On unmodified 26.2 this throws ConcurrentModificationException from HashMap.computeIfAbsent within those rounds, with cache as a ConcurrentHashMap it never does. Also, besides the crash, a concurrent HashMap insert can also silently lose a cache entry.

Notes:

Crashes were reproduced on modded servers (running several worlds at once is what makes concurrent first use of the same templates common, and allowed me to more easily reproduce the crash), but the race is entirely within vanilla's StructureTemplate$Palette and the proposed change of newHashMap to newConcurrentMap would fix the issue.

Same issue here on iPad gen. 6.