add test ensuring a moved mutex deadlocks
This commit is contained in:
parent
d3c1036255
commit
af98424285
@ -0,0 +1,16 @@
|
||||
//@error-in-other-file: deadlock
|
||||
//@normalize-stderr-test: "src/sys/.*\.rs" -> "$$FILE"
|
||||
//@normalize-stderr-test: "LL \| .*" -> "LL | $$CODE"
|
||||
//@normalize-stderr-test: "\| +\^+" -> "| ^"
|
||||
//@normalize-stderr-test: "\n *= note:.*" -> ""
|
||||
use std::mem;
|
||||
use std::sync::Mutex;
|
||||
|
||||
fn main() {
|
||||
let m = Mutex::new(0);
|
||||
mem::forget(m.lock());
|
||||
// Move the lock while it is "held" (really: leaked)
|
||||
let m2 = m;
|
||||
// Now try to acquire the lock again.
|
||||
let _guard = m2.lock();
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
error: deadlock: the evaluated program deadlocked
|
||||
--> RUSTLIB/std/$FILE:LL:CC
|
||||
|
|
||||
LL | $CODE
|
||||
| ^ the evaluated program deadlocked
|
||||
|
|
||||
note: inside `main`
|
||||
--> tests/fail/concurrency/mutex-leak-move-deadlock.rs:LL:CC
|
||||
|
|
||||
LL | $CODE
|
||||
| ^
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Reference in New Issue
Block a user