-
Notifications
You must be signed in to change notification settings - Fork 14k
std: use nonpoison::Mutex for all internal mutexes
#148689
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
base: master
Are you sure you want to change the base?
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
| #[stable(feature = "catch_unwind", since = "1.9.0")] | ||
| impl UnwindSafe for Stdin {} | ||
|
|
||
| #[stable(feature = "catch_unwind", since = "1.9.0")] | ||
| impl RefUnwindSafe for Stdin {} | ||
|
|
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.
The manual implementation is necessary to avoid a situation like #146087.
This comment has been minimized.
This comment has been minimized.
c5f4eac to
77d3da4
Compare
This comment has been minimized.
This comment has been minimized.
77d3da4 to
d75cc3b
Compare
|
If a panic happens anyway, do all these cases preserve correct internal state? If not, then we should actually keep propagating the panic through poisoning IMO. |
|
Maybe worth starting with the ones that we always I think for the ones that we sometimes just unwrap() on I'd lean towards keeping poisoning for the same reason outlined by @bjorn3 -- I'm not that convinced we lack bugs, and it seems like a cheap (good!) defense against those. |
They do.
I think it's important to keep in mind that such bugs would still result in a panic, and would hence need to corrupt the internal state in a way that leads to unsoundness before this would make a meaningful difference. |
Only on the thread where the buggy method was called. If this thread is never joined, without poisoning the panic will never propagate to any other threads. |
|
I'd like to point out that T-libs-api wants to switch @rustbot label +I-libs-api-nominated |
I think the default matters (and non-poison is probably the right default). But I'm not sure that means std can't use poisoned Mutexes anywhere -- that seems like a strange position to take. In ~95% of cases I'd tend to agree that they don't add value, but sometimes they do, and then we should aim to use them :) |
Under the hopefully reasonable assumption that
std's code is bug-free, all of the mutexes switched here will never be poisoned. The only poisoning mutex left is the one used for output capturing, as that has subtle effects on what gets captured.