Skip to content

[Bug]: Fabric recipe snapshot can throw ConcurrentModificationException #4

Description

@Exohayvan

Bug description

An anonymized error report captured an unhandled ConcurrentModificationException while Fabric copied recipe data during recipe-load handling.

This appears related to, but is not the same stack path as, #2: this report occurs in recipesLoaded while constructing a copy of the recipe map.

Affected code

net.exohayvan.dissolver_enhanced.data.EMCValues.recipesLoaded
EMCValues.java:495

The failing operation is equivalent to:

RECIPES = new HashMap<>(recipes);

The source recipe map appears to be modified concurrently while its entries are being copied.

Observed environment

  • Dissolver Enhanced: 1.5.32
  • Minecraft: 1.21.1
  • Loader: Fabric Loader 0.19.3
  • Java: 21
  • Runtime side: client

Stack trace

java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1605)
    at java.util.HashMap$EntryIterator.next(HashMap.java:1638)
    at java.util.HashMap.putMapEntries(HashMap.java:519)
    at java.util.HashMap.<init>(HashMap.java:492)
    at net.exohayvan.dissolver_enhanced.data.EMCValues.recipesLoaded(EMCValues.java:495)
    at net.exohayvan.dissolver_enhanced.data.EMCValues.recipesLoaded(EMCValues.java:510)
    at net.minecraft.world.item.crafting.RecipeManager
    at java.lang.Thread.run

Expected behavior

Recipe-load handling should take a stable snapshot or otherwise synchronize access before copying recipe data, so concurrent updates cannot crash the client.

Reproduction status

This came from an anonymized error report. Session identifiers, account information, IP/device details, operating system, and the full mod list are intentionally omitted. A deterministic reproduction is not yet available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Critical: makes the mod unusable or fully breaks core functionalityarea:emcEMC values, calculation, storage, or overridesarea:recipesRecipe loading, querying, snapshots, or derived EMCloader:fabricFabric-specificstatus:in-progressSomeone is actively implementing ittype:bugA defect or incorrect behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions