question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash when `WeightedPicker#search` called with argument out of expected range

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
apple502jcommented, Apr 14, 2022

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--/

1reaction
mwheelercommented, Apr 14, 2022

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Specified argument was out of the range of valid values ...
Visual Studio : 2012. Exception is thrown at the time of Showing Web Page Like, [ArgumentOutOfRangeException: Specified argument was out of the range...
Read more >
C# Exception Guide: ArgumentOutOfRangeException
The ArgumentOutOfRangeException exception is thrown when the value of an argument is outside the expected range of values as defined by the ...
Read more >
ArgumentException Class (System) - Microsoft Learn
ArgumentOutOfRangeException when the value of an argument is outside the range of acceptable values; for example, when the value "46" is passed as...
Read more >
Specified argument was out of the range of valid values ...
You are trying to access an array or List and specifying an index value that is either negative or larger than the largest...
Read more >
4. More Control Flow Tools — Python 3.11.1 documentation
To iterate over the indices of a sequence, you can combine range() and len() ... The actual parameters (arguments) to a function call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found