-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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?)
lovesegfault
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.