Skip to content

Commit 61a86e1

Browse files
committed
Windows lock primitives: check that we are truly sinle-threaded
1 parent 1e87c9f commit 61a86e1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/shims/foreign_items/windows.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
236236
| "LeaveCriticalSection"
237237
| "DeleteCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::")
238238
=> {
239+
assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported");
239240
// Nothing to do, not even a return value.
240241
// (Windows locks are reentrant, and we have only 1 thread,
241242
// so not doing any futher checks here is at least not incorrect.)
242243
}
243244
"TryEnterCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::")
244245
=> {
246+
assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported");
245247
// There is only one thread, so this always succeeds and returns TRUE
246248
this.write_scalar(Scalar::from_i32(1), dest)?;
247249
}

0 commit comments

Comments
 (0)