Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential deadlock in acquiring chunk locks for features chunks #2

Closed
Gegy opened this issue Feb 17, 2021 · 2 comments
Closed

Potential deadlock in acquiring chunk locks for features chunks #2

Gegy opened this issue Feb 17, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Gegy
Copy link

Gegy commented Feb 17, 2021

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

@ishland ishland added the bug Something isn't working label Feb 18, 2021
@ishland ishland assigned ishland and unassigned ishland Feb 18, 2021
@ishland
Copy link
Collaborator

ishland commented Feb 18, 2021

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.

@ishland ishland added the under review This doesn't seem right label Feb 18, 2021
@Gegy
Copy link
Author

Gegy commented Feb 18, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants