Auto merge of #1392 - RalfJung:win-lock-check, r=RalfJung

Windows lock primitives: check that we are truly single-threaded

Also rustup because why not.
This commit is contained in:
bors 2020-05-04 07:45:35 +00:00
commit a49234ebaf
3 changed files with 3 additions and 1 deletions

View File

@ -1 +1 @@
0a675c5e02e6ecfda7d4e04aabd23a9935e0c4bf
ff4df04799c406c8149a041c3163321758aac924

View File

@ -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)?;
}