-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Description
I expected this program not to cause a deadlock:
use loom::sync::{Arc, Mutex};
use loom::thread;
#[test]
fn try_lock() {
loom::model(|| {
let lock1 = Arc::new(Mutex::new(0));
let lock2 = lock1.clone();
let jh = thread::spawn(move || {
let _ = lock1.try_lock();
});
let guard = lock2.try_lock();
jh.join().unwrap();
drop(guard)
})
}But actually loom reports a deadlock:
thread 'try_lock' panicked at src/rt/execution.rs:215:13:
deadlock; threads = [(Id(0), Blocked(Location(Some(Location { file: "tests/mutex.rs", line: 16, col: 12 })))), (Id(1), Blocked(Location(Some(Location { file: "tests/mutex.rs", line: 11, col: 27 }))))]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
coroutine in thread 'try_lock' has overflowed its stack
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels