Mutex is failing me on multithreaded coroutines wi...
# kotlin-native
h
Mutex is failing me on multithreaded coroutines with
InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.sync.MutexImpl.LockedQueue
when accessed from two different threads, even though the documentation states:
All core communication and synchronization objects in
kotlin.coroutines
such as Job, Deferred, Channel, BroadcastChannel, Mutex, and Semaphore are shareable. It means that they can be frozen for sharing with another thread and still continue to operate normally.
Anyone experienced this?
k
confusingly, that same exception will be thrown when k/n expects something to be frozen and it's not
if that's not the issue then it may be a bug
h
True, and as far as I understand it's throwing this exception while setting the (optional) owner parameter, so that seems like a bug to me
Copy code
at kfun:kotlinx.coroutines.sync.MutexImpl.LockedQueue.<set-owner>#internal (0000000000589100)
        at kfun:kotlinx.coroutines.sync.MutexImpl.unlock(kotlin.Any?) (00000000005875a0)
But also might be hiding another problem, or a missunderstanding how Kotlin/Native Mutexes should be used