Skip to content

Commit 877dfeb

Browse files
authored
Auto merge of #35378 - Amanieu:rwlock_eagain, r=alexcrichton
Handle RwLock reader count overflow `pthread_rwlock_rdlock` may return `EAGAIN` if the maximum reader count overflows. We shouldn't return a successful lock in that case.
2 parents ddf92ff + dff62c1 commit 877dfeb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libstd/sys/unix/rwlock.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ impl RWLock {
5050
// the implementation allows recursive locking. The POSIX standard
5151
// doesn't require recursivly locking a rwlock to deadlock, but we can't
5252
// allow that because it could lead to aliasing issues.
53-
if r == libc::EDEADLK || *self.write_locked.get() {
53+
if r == libc::EAGAIN {
54+
panic!("rwlock maximum reader count exceeded");
55+
} else if r == libc::EDEADLK || *self.write_locked.get() {
5456
if r == 0 {
5557
self.raw_unlock();
5658
}

0 commit comments

Comments
 (0)