-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Unix: RwLock is incorrect #53127
Copy link
Copy link
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.
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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I think the
sys::unix::rwlockimplementation is incorrect in the sense that it has undefined behavior, for two reasons:The access toThis is fixed.write_lockedis not properly synchronized: Inread, we accesswrite_lockedeven ifpthread_rwlock_rdlockfailed.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?)