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

Fix deadlock race when acquire is cancelled #2

Merged
merged 1 commit into from
Jan 25, 2020

Conversation

mtharp
Copy link
Contributor

@mtharp mtharp commented Dec 16, 2019

If the waiter goroutine is signaled before the section guarding canceledAcquireCount has run, then there is a deadlock because the only goroutine that can release the lock has already re-acquired it. Scheduling the second goroutine before locking ensures that one of the two can release the lock and keep things moving.

If the waiter goroutine completes before the section guarding
canceledAcquireCount has run, then there is a deadlock because there is
nothing that can unlock the mutex. Scheduling the second goroutine
ensures that one of the two can release the lock and keep things moving.
jackc added a commit that referenced this pull request Jan 25, 2020
Detect bug fixed by 26cd25c. See also
#2.
@jackc jackc merged commit 26cd25c into jackc:master Jan 25, 2020
@jackc
Copy link
Owner

jackc commented Jan 25, 2020

Merged with the improvement of the stress test such that it would have caught this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants