-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explain our RwLock implementation #71889
Conversation
src/libstd/sys/unix/rwlock.rs
Outdated
self.raw_unlock(); | ||
} | ||
panic!("rwlock write lock would result in deadlock"); | ||
} else { | ||
debug_assert_eq!(r, 0); | ||
assert_eq!(r, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this from a debug assert? The docs for pthread_rwlock_wrlock
specify that it only ever returns EDEADLK
or 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency -- I did the same in #55865. Seems cheap to check.
But if you want I can also make it a debug assertion again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer making it a debug assert since this is a pretty hot path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I did that and added an appropriate comment.
Is it generally the case that the list of error codes in the POSIX docs is exhaustive? I noticed the docs explicitly say "These functions shall not return an error code of [EINTR]" but do not say that for any of the other error codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are supposed to be exhaustive in theory.
@bors r+ |
📌 Commit f9866f9 has been approved by |
@bors rollup |
Explain our RwLock implementation Turns out that [with the latest POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_wrlock.html), our `RwLock` implementation is actually correct. However, we cannot fully rely on that due to bugs in older glibc (fix released in 2016). Update the comments to explain that. I also clarified our Mutex docs a bit and fixed another instance of rust-lang#55865. r? @Amanieu Fixes rust-lang#53127
Explain our RwLock implementation Turns out that [with the latest POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_wrlock.html), our `RwLock` implementation is actually correct. However, we cannot fully rely on that due to bugs in older glibc (fix released in 2016). Update the comments to explain that. I also clarified our Mutex docs a bit and fixed another instance of rust-lang#55865. r? @Amanieu Fixes rust-lang#53127
Explain our RwLock implementation Turns out that [with the latest POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_wrlock.html), our `RwLock` implementation is actually correct. However, we cannot fully rely on that due to bugs in older glibc (fix released in 2016). Update the comments to explain that. I also clarified our Mutex docs a bit and fixed another instance of rust-lang#55865. r? @Amanieu Fixes rust-lang#53127
Explain our RwLock implementation Turns out that [with the latest POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_wrlock.html), our `RwLock` implementation is actually correct. However, we cannot fully rely on that due to bugs in older glibc (fix released in 2016). Update the comments to explain that. I also clarified our Mutex docs a bit and fixed another instance of rust-lang#55865. r? @Amanieu Fixes rust-lang#53127
Rollup of 6 pull requests Successful merges: - rust-lang#71510 (Btreemap iter intertwined) - rust-lang#71727 (SipHasher with keys initialized to 0 should just use new()) - rust-lang#71889 (Explain our RwLock implementation) - rust-lang#71905 (Add command aliases from Cargo to x.py commands) - rust-lang#71914 (Backport 1.43.1 release notes to master) - rust-lang#71921 (explain the types used in the open64 call) Failed merges: r? @ghost
Turns out that with the latest POSIX docs, our
RwLock
implementation is actually correct. However, we cannot fully rely on that due to bugs in older glibc (fix released in 2016). Update the comments to explain that.I also clarified our Mutex docs a bit and fixed another instance of #55865.
r? @Amanieu
Fixes #53127