You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mutex stays locked when a stop races with unlock #66
Mutex::LockAwaiter can throw CancelledException after unlock() has already handed it the lock, leaving the mutex locked forever.
A coroutine is suspended in co_await mutex.lock().
Its stop is requested. The cancellation is posted and has not run yet.
The holder calls unlock(). resume_now takes the waiter and resumes it; locked_ stays true, as ownership is passed to the waiter.
await_resume sees token.stop_requested() and throws.
Nobody owns the lock now, so locked_ is never cleared and every later lock() waits forever.
This predates #65 (the old check token.stop_requested() && !(active && *active) behaves the same). A fix could be to throw only when the cancellation resumed the waiter (e.g. a cancelled flag set in the register_cancel action, as the other awaiters do), or to unlock before throwing.
Activity