From 61a86e1ffea5bbda721ab2d2702807f085e2a3a4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 4 May 2020 09:37:40 +0200 Subject: [PATCH] Windows lock primitives: check that we are truly sinle-threaded --- src/shims/foreign_items/windows.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shims/foreign_items/windows.rs b/src/shims/foreign_items/windows.rs index a58444b21bf..f55b5b8450e 100644 --- a/src/shims/foreign_items/windows.rs +++ b/src/shims/foreign_items/windows.rs @@ -236,12 +236,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx | "LeaveCriticalSection" | "DeleteCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::") => { + assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported"); // Nothing to do, not even a return value. // (Windows locks are reentrant, and we have only 1 thread, // so not doing any futher checks here is at least not incorrect.) } "TryEnterCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::") => { + assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported"); // There is only one thread, so this always succeeds and returns TRUE this.write_scalar(Scalar::from_i32(1), dest)?; }