Skip to content

Commit ccd4081

Browse files
committed
Fix comments and tests
1 parent 8d4111c commit ccd4081

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/concurrency/genmc/intercept.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2727
.expect("This function should only be called in GenMC mode.");
2828

2929
let get_mutex_call_infos = || {
30-
// assert!(!args.is_empty());
3130
assert_eq!(args.len(), 1);
3231
let arg = this.copy_fn_arg(&args[0]);
3332
let addr = this.read_target_usize(&arg)?;

tests/genmc/fail/intercept/mutex_deadlock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//@compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows
22
//@error-in-other-file: unsupported operation
33

4-
// TODO
4+
// Test that we can detect a deadlock involving `std::sync::Mutex` in GenMC mode.
5+
// FIXME(genmc): The error message for such deadlocks is currently not good, it does not show both involved lock call locations.
56

67
#![no_main]
78
#![feature(abort_unwind)]

tests/genmc/pass/intercept/mutex_simple.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,23 @@ fn main_() {
5454
assert!(LOCK.try_lock().is_ok()); // Trying to lock now should *not* fail since the lock is not held.
5555
}
5656

57-
let ids = [
58-
spawn_pthread_closure(|| {
59-
for _ in 0..REPS {
60-
let mut guard = LOCK.lock().unwrap();
61-
guard[0] += 2;
62-
}
63-
}),
64-
spawn_pthread_closure(|| {
65-
for _ in 0..REPS {
66-
let mut guard = LOCK.lock().unwrap();
67-
guard[0] += 4;
68-
}
69-
}),
70-
];
71-
unsafe { join_pthreads(ids) };
57+
unsafe {
58+
let ids = [
59+
spawn_pthread_closure(|| {
60+
for _ in 0..REPS {
61+
let mut guard = LOCK.lock().unwrap();
62+
guard[0] += 2;
63+
}
64+
}),
65+
spawn_pthread_closure(|| {
66+
for _ in 0..REPS {
67+
let mut guard = LOCK.lock().unwrap();
68+
guard[0] += 4;
69+
}
70+
}),
71+
];
72+
join_pthreads(ids);
73+
}
7274

7375
let guard = LOCK.lock().unwrap();
7476
assert!(guard[0] == REPS * 6); // Due to locking, all increments should be visible in every execution.

0 commit comments

Comments
 (0)