Concurrent Chunk Management Engine (Fabric)

Concurrent Chunk Management Engine (Fabric)

231k Downloads

Potential deadlock in acquiring chunk locks for features chunks

Gegy opened this issue ยท 2 comments

commented

From what I can tell, there seems to be the potential for a deadlock to occur when acquiring chunk locks for loading the features chunk status. This can happen given locks are acquired sequentially: if two chunks are acquiring the same locks at the same time, they can end up in a state where they both have acquired some of their locks, but the other thread holds the rest that they need. This causes no progression to be possible, given they are both waiting on each other to release the locks.

Working around this would require atomically ensuring that all locks are available before acquisition, but I'm not sure how this would work with the asyncutil library.

https://github.com/YatopiaMC/barium-fabric/blob/e05b0cd6b08dd3828b8c96aa6c4f36dda9112af9/src/main/java/org/yatopiamc/barium/common/threading/worldgen/ChunkStatusUtils.java#L35-L54

commented

Locks are not acquired synchronously though: the thread will yield to other tasks if it encounters an acquired lock.

commented

All generation task scheduling is done on a single thread executor. So there isnt't the case where multiple threads are executing this method.

It is a good idea to clean up this dirty method though.