Mo' Structures (NeoForge/Fabric)

Mo' Structures (NeoForge/Fabric)

9M Downloads

Race condition in bordering chunk checks

kylerhenry opened this issue ยท 15 comments

commented

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.

commented

I have a PR to fix this if you grant me access

commented

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

commented

Yea, can do it that way too. Gimme a min

commented

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

commented

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.

commented

And we use that method already

commented

My apologies, was looking at the wrong docs. NeoForge does support a getBaseHeight, but yall are already using the Yarn equivalent as pointed out.

commented

Seed: 915608189789875723
Pos when crashed:
X: 4578.82
Y: 133.44
Z: -8134.92

commented

Thank you, I will investigate as soon as possible. This was on NeoForge?

commented

Yes correct neoforge ATM10 modpack

commented

Not reproducing on Vanilla Fabric + Mo' Structures on 1.21.8. Will test on the modpack.

commented

Couldn't reproduce on ATM10 modpack at given seed and coordinates. Could I get a video or some other trigger for the crash?
for instance, was this on a server

Image
commented

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

commented

I'll check on a server but both logs show some sort of crash due to entity collision grabbing chunks. We have plenty of structures generating close to each other so that they would check each other like this scenario and no crash really ever happens