Closed
Description
I think the sys::unix::rwlock
implementation is incorrect in the sense that it has undefined behavior, for two reasons:
The access toThis is fixed.write_locked
is not properly synchronized: Inread
, we accesswrite_locked
even ifpthread_rwlock_rdlock
failed.- Worse, POSiX read-write locks have UB when the thread holding the write lock attempts to acquire it again -- and yet nothing is stopping exactly that from happening in
write
. If we really want to use POSIX rwlocks, I think we have to implement a reentrancy detector. (And then maybe we also want to use that for mutex, so that we can use the static initializer and the most efficient code path?)