-
Notifications
You must be signed in to change notification settings - Fork 5
Description
TLDR:
Geocluster is not entirely Thread-Safe and when generating multi-Chunk spanning Deposits like sparse-deposits it can cause a concurrent-access violation when used with C2ME which parallelizes world generation.
What happened:
On my Modpack with C2ME and Geocluster I was encounter thread-safety related crashes when enabling modded ores in Geocluster. After some digging I isolated the issue to C2ME's parallelized world Generation and Geocluster not being made for multi-thread operations on that scale.
Where does it happen:
When Geocluster generates large ore deposits, it can sometimes generate deposits that spill over into neighbouring chunks. In some cases these Chunks are not yet done generating. The original Code in Geocluster already handles the case where the Chunk is not yet in the right generation State, however it does not handle the case where the Chunk isn't even on the same Thread. By checking whether the chunk we want to place blocks in is the same as our "execution-chunk" we can essentially check if we are trying to reach across threads. In this case, we defer the block placement until later via the already implemented Deferment Logic.
Fixing
My proposed fix is already explained in the above segment, however I also made a Fork implementing this. As I explain in the Readme over there, This implementation does come with some edge cases and issues, but most of these should be solvable with some thinking. Of course, there might be a much better Idea for thread safety just around the corner.
I deliberately did not make this Fork a Pull Request, since it seemed much to niche of an issue to me, and doesn't really constitute a bug or anything, but rather a compatibility issue caused by the design of C2ME and Geocluster respectively.