-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Data race in Mutex.withLock #3250
Comments
https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/common/src/sync/Mutex.kt#L173 must be there for this behavior: |
@dkhalanskyjb is correct if the memory model is sequentially consistent. Otherwise, a The behavior never occurs on x86, and the race affects the implementation only when the Mutex is used incorrectly, without breaking its internal structure. The issue will be fixed soon with a new Mutex implementation in #3020. |
Hey there,
Similar to #2660, our internal Java TSAN tests in Google picked up a race in Mutex.kt
This surfaced in a bit of code that is using
mutex.withLock
to ensure thread safety in a caching function.It appears that
state.owner
is written to at Mutex.kt:341, and read from Mutex.kt:173, potentially from different threads, is this something that we should be concerned about?Thanks!
The text was updated successfully, but these errors were encountered: