Skip to content
This repository has been archived by the owner on Nov 18, 2019. It is now read-only.

Fix deadlock issue with nose-goes #48

Merged
merged 2 commits into from
Jul 11, 2017
Merged

Conversation

randomPoison
Copy link
Owner

So you know how Rust is all good and stuff? Well it doesn't fix all bugs. In this case, it's still possible to deadlock if a thread grabs a mutex's lock and never lets go. In this case, the game thread was meant to release the lock on the nose-goes mutex before sleeping, but it never did. The thread held the mutex lock during its entire sleep, and would only release it briefly before returning to the top of the loop, where it would almost immediately re-acquire the lock. As a result, the thread handling the nose-goes request would never be able to acquire the lock, and would never manage to remove the player from the nose-goes event. This would result in players who successfully tapped the poison pill to still be killed in a nose-goes event.

I've fixed this by adding an explicit scope to the game loop to ensure the mutex guard for the nose-goes state is dropped at the right time. I've also added a note to remind others to be wary of the same issue in the future. If we keep running into this issue, we can further abstract the game loop such that these issues can't happen anymore, but I haven't bothered at this point.

@randomPoison randomPoison merged commit d753bdb into master Jul 11, 2017
@randomPoison randomPoison deleted the nose-goes-deadlock branch July 11, 2017 14:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant