Crash when loading world: java.util.ConcurrentModificationException when using Java 11 or above
When attempting to play attached world in Minecraft client, game may crash, then freeze. Doesn't always happen. Crash report is only printed in launcher, not saved.
java.util.ConcurrentModificationException at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134) at cje.b(SourceFile:67) at cje.a(SourceFile:57) at cff.a(SourceFile:98) at cfi.a(SourceFile:86) at java.base/java.util.stream.ReferencePipeline$4$1.accept(ReferencePipeline.java:212) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:496) at java.base/java.util.stream.IntPipeline.max(IntPipeline.java:459) at cfi.a(SourceFile:86) at cfd$c.a(SourceFile:175) at java.base/java.util.stream.ReferencePipeline$4$1.accept(ReferencePipeline.java:212) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:496) at java.base/java.util.stream.IntPipeline.max(IntPipeline.java:459) at cfd$c.a(SourceFile:176) at cfd$c.<init>(SourceFile:98) at cfd.a(SourceFile:280) at cet.a(SourceFile:25) at ces$a.a(SourceFile:89) at bwy.a(SourceFile:187) at bxc.d(SourceFile:44) at bxc.a(SourceFile:199) at us.a(SourceFile:461) at com.mojang.datafixers.util.Either$Left.map(Either.java:38) at us.a(SourceFile:455) at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1072) at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478) at uu.b(SourceFile:57) at agk.e(SourceFile:83) at agk.a(SourceFile:123) at agk.run(SourceFile:91) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Environment
Java 11 or newer
Created Issue:
Crash when loading world
When attempting to play attached world in Minecraft client, game may crash, then freeze. Doesn't always happen. Crash report is only printed in launcher, not saved.
When attempting to play attached world in Minecraft client, game may crash, then freeze. Doesn't always happen. Crash report is only printed in launcher, not saved.
1.14: crashreport.txt
java.util.ConcurrentModificationException at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134) at cje.b(SourceFile:67) at cje.a(SourceFile:57) at cff.a(SourceFile:98) at cfi.a(SourceFile:86) at java.base/java.util.stream.ReferencePipeline$4$1.accept(ReferencePipeline.java:212) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:496) at java.base/java.util.stream.IntPipeline.max(IntPipeline.java:459) at cfi.a(SourceFile:86) at cfd$c.a(SourceFile:175) at java.base/java.util.stream.ReferencePipeline$4$1.accept(ReferencePipeline.java:212) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.IntPipeline.reduce(IntPipeline.java:496) at java.base/java.util.stream.IntPipeline.max(IntPipeline.java:459) at cfd$c.a(SourceFile:176) at cfd$c.<init>(SourceFile:98) at cfd.a(SourceFile:280) at cet.a(SourceFile:25) at ces$a.a(SourceFile:89) at bwy.a(SourceFile:187) at bxc.d(SourceFile:44) at bxc.a(SourceFile:199) at us.a(SourceFile:461) at com.mojang.datafixers.util.Either$Left.map(Either.java:38) at us.a(SourceFile:455) at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1072) at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478) at uu.b(SourceFile:57) at agk.e(SourceFile:83) at agk.a(SourceFile:123) at agk.run(SourceFile:91) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Crash when loading worldCrash when loading world: java.util.ConcurrentModificationException when using Java 11
Crash when loading world: java.util.ConcurrentModificationException when using Java 11 or above
Java 11 or newer
is duplicated by
is duplicated by
is duplicated by
Thank you for your report!
We're actually already tracking this issue in MC-149777, so I resolved and linked this ticket as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature in the future to see if the issue has already been reported.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – ✍️ Feedback and Suggestions – 📖 Game Wiki
What version of Java are you using? If it's Java 11 or above, you may have run into MC-149777.
Thank you for your report!
We're tracking this issue in MC-149777, so this ticket is being resolved and linked as a duplicate.
That ticket has already been resolved as Fixed. Please check the Fix Version/s field in that ticket to see in which version this behavior was or will be fixed.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
This might happen because you're using a newer version of Java than it was designed for. The Minecraft launcher currently recommends Java 8 Update 51. (Nevertheless, Minecraft should work with newer Java versions.)
Still occurs with 1.14.1-pre1. pre1.txt
Acual fix: https://github.com/modmuss50/Voyager/blob/1.0.0/src/main/java/me/modmuss50/voyager/mixin/StructureManagerMixin.java
Maity, may I ask what that .java file does?
That should be treated as the code analysis and fix suggestion. It shows why the crash can happen (because worldgen and server threads use the structure manager hash map concurrently)
Is this still an issue in 1.15.2?
Greymagic27, Yes, I have problems loading worlds in both singleplayer and multiplayer, basically showing the same crash error.
I will be using yarn names throught this comment:
I spent sometime looking into the best way of fixing this. I came to the conclusion that using Collections.synchronizedMap() is the ideal fix. The reason for using this over ConcurrentHashMap is HashMap allows null values, where as ConcurrentHashMap does not, this is important as in getStructureOrBlank a null map value is possible if the structure could not be found, synchronizedMap does not change the implimentation details of HashMap.
The mixin linked above is the old method, [StructureManagerMixin.java|https://github.com/modmuss50/Voyager/blob/master/src/main/java/me/modmuss50/voyager/mixin/StructureManagerMixin.java] shows how I achieved this using Collections.synchronizedMap()
Confirmed for 20w13b.
This just randomly happened to me in 1.15.2 in my vanilla survival world.
I was playing in the world for a while, went exploring, and while riding with a boat across an ocean, this just happened. I'm playing in the world since 1.14, and I'm using Java 12.
Confirmed to still be an issue in 20w15a
Still in 20w18a
I have repoduced this in 20w21a, however it was only logged to console and didnt crash the game. I still believe the hard crash can still happen as the code appears untouched since it was last reproduced in 20w18a.
20w21a_log.txt
I know this exception. I've encountered it before multiple times. It's due to a change in Java 11 that makes it so HashMap.computeIfAbsent will throw this exception, either if the call is nested, or if something else interacts with the collection whilst that method is being called.
map.computeIfAbsent(keyOne, a -> { .... return map.computeIfAbsent(keyTwo, b -> { }); // throws });Only solution I know of is to switch to using something like a TreeMap instead, which does not have it's own implementation of computeIfAbsent.
Does this affect the latest release 1.16.4?
Yes it does.
This bug is caused mainly by bad programming that mojang refuses to fix even though it isn't hard to fix. As a workaround, you can use the fabric modloader with the fabric API installed, or you can use java 8.
Given 21w19a now has a dependency on Java 16, I'd recommend a fix for this issue before release.
was gonna make my own bug report but I saw this and this is close enough,
servers for 21w19a crash when loading my world that was created in 21w18a

so if this is fixable by me (I assume I need to download Java 16?) how do I fix it and how do I upgrade to Java 16
It also wont start a fresh server with no worlds yet. Wont even generate the needed files such as the Eula or server properties. This is bad for me because I play 80% on servers so my friend can join when we want instead of having them visit me and use LAN.
EDIT: This was simply because I didn't have Java 16 installed.
this is not suited for the bugtracker, but as I assume this ticket is going to attract many of these questions, answer is go to https://adoptopenjdk.net and follow some simple installation prompts, make sure to download java version 16.
Zytron, that is a different issue than this bug. You need to install Java 16 to be able to run the server after 21w19a, and I'd suggest you go to Community Support if you need further assistance.