You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On linux pthread_rwlock_rdlock/wrlock return EDEADLK if you attempt to take the other type of lock when you own one. libstd ignores this when debug-assertions are not on, and then will try to unlock twice anyway. This leads to arbitrarily bad behavior (on playpen it happens to hit x86-HLE code and SIGILL):
use std::sync::RwLock;
fn main() {
let x = RwLock::new("");
let _w = x.write().unwrap();
let _r = x.read().unwrap();
}
The text was updated successfully, but these errors were encountered:
Apparently implementations are allowed to return EDEADLK instead of blocking
forever, in which case this can lead to unsafety in the `RwLock` primitive
exposed by the standard library. A debug-build of the standard library would
have caught this error (due to the debug assert), but we don't ship debug
builds right now.
This commit adds explicit checks for the EDEADLK error code and triggers a panic
to ensure the call does not succeed.
Closesrust-lang#25012
Apparently implementations are allowed to return EDEADLK instead of blocking
forever, in which case this can lead to unsafety in the `RwLock` primitive
exposed by the standard library. A debug-build of the standard library would
have caught this error (due to the debug assert), but we don't ship debug
builds right now.
This commit adds explicit checks for the EDEADLK error code and triggers a panic
to ensure the call does not succeed.
Closes#25012
On linux pthread_rwlock_rdlock/wrlock return EDEADLK if you attempt to take the other type of lock when you own one. libstd ignores this when debug-assertions are not on, and then will try to unlock twice anyway. This leads to arbitrarily bad behavior (on playpen it happens to hit x86-HLE code and SIGILL):
The text was updated successfully, but these errors were encountered: