]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/windows_join_main.rs
Auto merge of #102573 - RalfJung:mirisync, r=oli-obk
[rust.git] / src / tools / miri / tests / fail / concurrency / windows_join_main.rs
1 //@only-target-windows: Uses win32 api functions
2 // We are making scheduler assumptions here.
3 //@compile-flags: -Zmiri-preemption-rate=0
4
5 // On windows, joining main is not UB, but it will block a thread forever.
6
7 use std::thread;
8
9 extern "system" {
10     fn WaitForSingleObject(handle: isize, timeout: u32) -> u32;
11 }
12
13 const INFINITE: u32 = u32::MAX;
14
15 // XXX HACK: This is how miri represents the handle for thread 0.
16 // This value can be "legitimately" obtained by using `GetCurrentThread` with `DuplicateHandle`
17 // but miri does not implement `DuplicateHandle` yet.
18 const MAIN_THREAD: isize = (2i32 << 30) as isize;
19
20 fn main() {
21     thread::spawn(|| {
22         unsafe {
23             assert_eq!(WaitForSingleObject(MAIN_THREAD, INFINITE), 0); //~ ERROR: deadlock: the evaluated program deadlocked
24         }
25     })
26     .join()
27     .unwrap();
28 }