Crash when `WeightedPicker#search` called with argument out of expected range
eizengan opened this issue ยท 13 comments
The following error crashed my server several times while generating terrain for minecraft:the_end
with Chunky
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: The provided target value for entry selection must be less than or equal to the weight total
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.IllegalArgumentException: The provided target value for entry selection must be less than or equal to the weight total
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at net.fabricmc.fabric.impl.biome.WeightedPicker.search(WeightedPicker.java:79)
at net.fabricmc.fabric.impl.biome.WeightedPicker.pickFromNoise(WeightedPicker.java:56)
at net.fabricmc.fabric.impl.biome.TheEndBiomeData$Overrides.pick(TheEndBiomeData.java:132)
at net.minecraft.class_2169.handler$zzc000$getWeightedEndBiome(class_2169.java:546)
at net.minecraft.class_2169.method_38109(class_2169.java:82)
at net.minecraft.class_2826.method_38291(class_2826.java:200)
at net.minecraft.class_2791.method_38257(class_2791.java:393)
at net.minecraft.class_3754.method_38327(class_3754.java:134)
at net.minecraft.class_3754.method_38333(class_3754.java:124)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
... 6 more
A full crash report is available here
Is this an issue with the Fabric API, as it appears?
Caused by: java.lang.IllegalArgumentException: The provided target value for entry selection must be less than or equal to the weight total
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at net.fabricmc.fabric.impl.biome.WeightedPicker.search(WeightedPicker.java:79)
at net.fabricmc.fabric.impl.biome.WeightedPicker.pickFromNoise(WeightedPicker.java:56)
This only seems possible if the noise sampler is returning something greater than 1 here?
It is created here:
Unfortunately, the error message doesn't show the numbers so we can't see if they have weird values.
I don't know enough about the minecraft noise generation to know how such values are possible or how/if chunky is causing them? Sometimes things like random number generators (especially seeded ones) are not meant to be used concurrently, which chunky might be causing to happen, if it is even relevant in this case?
I can also tell from chunky's build that the fabric part wasn't tested with 1.18.2 (it uses an older fabric api). Tnere were major changes in this code: #1989
I can also tell from chunky's build that the fabric part wasn't tested with 1.18.2 (it uses an older fabric api). Tnere were major changes in this code: #1989
Sounds like I may need to open an issue on Chunky instead ๐ค
Sounds like I need to open an issue on Chunky instead ๐ค
At first glance I wouldn't say it is chunky. It is not using this fabric api directly.
Sometimes things like random number generators (especially seeded ones) are not meant to be used concurrently, which chunky might be causing to happen, if it is even relevant in this case?
Just to clarify, chunky uses a separate thread to run scheduling logic and so on, but the actual generation is done on the main server thread as can be seen here, specifically so those sorts of dangerous behaviors can be avoided.
I can also tell from chunky's build that the fabric part wasn't tested with 1.18.2 (it uses an older fabric api).
It's been tested on 1.18.2, and most of the mod's downloads are on this version so I'd imagine it's not a problem. I don't see anything in the change set you linked which seems particularly relevant.
Not sure what best practices are in bumping fabric API and loader versions so feel free to call me out if there's anything I should be doing better. I usually just try to leave it at the lowest tested version for compatibility.
At first glance I wouldn't say it is chunky. It is not using this fabric api directly.
Yeah that'd be my opinion as well. I normally would expect this to be an issue with another mod, though strangely this stack trace doesn't show any obvious culprits.
I run a pretty lean modlist; this server is basically just vanilla + performance mods. Prior to the crash linked above I archived all my mods except Chunky and Fabric API and restarted as an attempt to remediate, so it seems unlikely that the crash isn't resulting from one of those? I suppose mods which play with chunk storage (e.g. Starlight) could have left something in a weird state. Given the very generic backtrace and my lack of Java expertise I doubt I can dig any deeper without guidance, though I am happy to do so!
If it helps, here is a comprehensive list of the mods which have touched the server:
Current:
- Chunky-1.2.164.jar
- fabric-api-0.50.0+1.18.2.jar
- ferritecore-4.2.0-fabric.jar
- krypton-0.1.9.jar
- lazydfu-0.1.2.jar
- lithium-fabric-mc1.18.2-0.7.9.jar
- spark-1.8.14-fabric.jar
- starlight-1.0.2+fabric.89b8d9f.jar
Previous, removed prior to error:
- phosphor-fabric-mc1.18.x-0.8.1.jar (removed in favor of starlight)
- fabric-api-0.48.0+1.18.2 (updated)
- fabric-api-0.47.9+1.18.2 (updated)
Does this happen when generating the terrain with the same seed?
I don't think this is the case given how perlin noise is implemented - but AtomicSimpleRandom is a concern, since vanilla has a bug that causes a miscalculation and disparity with java.util.Random
(see https://bugs.mojang.com/browse/MC-239059)
I can say Krypton, LazyDFU, Spark, and Starlight are not relevant; FerriteCore isn't, probably. Lithium needs investigation although I believe the one PR touching noise sampler didn't get merged.
I can confirm this is an issue with fabric-api on it's own (no other mods), info to repro:
- create world w/ seed:
6125739175483036084
/execute in minecraft:the_end run tp @a -1200 64 -240
- wait for chunks to load (I had 19 chunk radius i think, so it's one of the chunks 'around' that location, i'm not sure which one specifically)
crashes the same w/ 0.47.10, 0.48.0, and 0.50 in MC 1.18.2
Finished work, was able to download/build fabric and run this through a debugger to inspect the target
value & find a more reliable repro location.
New tp command: /execute in minecraft:the_end run tp @a -1312 64 -800
(should crash even w/ low chunk radius / should be in that chunk - I've updated my previous comment):
-- Chunk to be generated --
Details:
Location: -82,-50
Position hash: -210453397586
Generator: net.minecraft.world.gen.chunk.NoiseChunkGenerator@5cba22c
The target
variable in this case is 1.0002144374246198
in my repro case... guessing it's an issue w/ MC's perlin noise implementation (probably some sort of error accumulation resulting in a tiny bit of overflow that causes results not to strictly be in the [0.0, 1.0] range all of the time).
Seems not too uncommon in some seeds? (I've found multiple places this crashes in my seed) - so I'd say it's a serious bug (definitely has stopped me from being able to play my world this weekend unless I fudge my own local build of fabric-api to add an allowed bias over 1.0)
If perlin noise generator does return values above 1.0 that'd be a big bug. Checking.
Okay, yeah PerlinNoiseSampler
is buggy.
It seems like some versions of perlin noise can in fact produce values >= 1: see https://www.gamedev.net/forums/topic/285533-2d-perlin-noise-gradient-noise-range--/
Appreciate you all handling repro and other detective work! Can I can provide any other info to help, or am I correct about this being firmly in "wait for a fix" territory?
I'm also having this similar issue. I slowly removed mods and also found that with only have fabric-api-0.51.1+1.18.2
the game would crash when generating specific end chunks.
Once I removed that last mod and relaunching the fabric server I was able to manually generate End chunks again without the server immediately crashing.
Seed: -7207838482970946636
Problem chunks: End Chunks going East from the Island