
Race condition in bordering chunk checks
kylerhenry opened this issue ยท 15 comments
crash-2025-07-24_16.27.18-server.txt
World generation worker thread (Worker-Main-153) gets stuck in calculation. The thread dump points directly to the Mo' Structures mod as the cause.
The server was trying to find a valid location to place a structure from this mod when it got stuck:
at TRANSFORMER/[email protected]+1.21/io.github.frqnny.mostructures.structure.ModStructure.findGenerationPoint(ModStructure.java:77)
canGenerate
method in this mod:
https://github.com/frqnny/mostructures/blob/1.21.x/common/src/main/java/io/github/frqnny/mostructures/structure/ModStructure.java#L89-L106
Possibly just takes a long time to generate?
When a worker thread is generating Chunk A, this code asks the chunkGenerator for the final surface height of 24 other nearby chunks.
If one of those nearby chunks (Chunk B) is also being generated by a different worker thread, the first thread (for Chunk A) has to stop and wait for the second thread (for Chunk B) to finish its work. If the thread for Chunk B also needs to check the height of Chunk A for one of its own structures, it will wait for the first thread.
I think you don't need access to create a PR, do you? clone the repo, modify what you need, commit it at your repo and after that, create a PR
if you can fix the canGenerate method, I will release some new structures I have waiting on 1.21.8 with the fix and backport the new structures to 1.21.1 sometime today
The PR doesn't seem to use existing code ? I would like to investigate this issue further, so if you have a world seed and coordinates where this issue happens, it would be appreciated.
My apologies, was looking at the wrong docs. NeoForge does support a getBaseHeight, but yall are already using the Yarn equivalent as pointed out.
Not reproducing on Vanilla Fabric + Mo' Structures on 1.21.8. Will test on the modpack.
I managed to dig up the crash file. This is all the info I have. It's on a local linux dedicated server running in a docker container - 16 cores and 18GB RAM dedicated to it.
crash-2025-07-24_16.27.18-server.txt