-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Mutex is unlocked on cancellation #4145
Comments
Steps to reproduce:
|
The code in the example still has a bug. Even if The modified repro consistently has two failure modes:
It doesn't seem like we can do much (assuming that my reproducer reflects the actual failure mode). |
Possibly related to #2683.
Hi, we have had a bug report where users are seeing an exception from Mutex bubble up.
Here's the stack trace a user shared:
Where
Continuation at ba.u$b is: androidx.compose.foundation.gestures.PressGestureScopeImpl$reset$1 -> ba.u$b:
.reset
is here.Users are seeing this on Samsung, Motorola and Xioami devices, on SDK 30 - 34.
From the stack trace, the only explanation I can think of is this sequence:
If acquiring the semaphore takes longer than dispatching the unlock, the mutex would already be unlocked when the continuation's cancellation clause is invoked. Although I don't have an explanation why the permit acquisition would take longer.
A similar scenario is also outlined by @dkhalanskyjb here. From an API PoV, I am not sure how to guard against this, but the cancellation of a lock acquisition should always be safe as we would otherwise need to track ongoing acquisitions.
Provide a Reproducer
No repro case just yet, will update if I find one. I could imagine something like this:
Version: Users originally reported this starting in Compose Foundation 1.4.3, where we were using Coroutines 1.6.4. Users have also reported this in Compose Foundation 1.6.0, where we are using Coroutines 1.7.3.
Let me know if there is anything else I can provide. Thanks!
The text was updated successfully, but these errors were encountered: