]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/windows_join_self.rs
Auto merge of #105262 - eduardosm:more-inline-always, r=thomcc
[rust.git] / src / tools / miri / tests / fail / concurrency / windows_join_self.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, a thread joining itself is not UB, but it will deadlock.
6
7 use std::thread;
8
9 extern "system" {
10     fn GetCurrentThread() -> usize;
11     fn WaitForSingleObject(handle: usize, timeout: u32) -> u32;
12 }
13
14 const INFINITE: u32 = u32::MAX;
15
16 fn main() {
17     thread::spawn(|| {
18         unsafe {
19             let native = GetCurrentThread();
20             assert_eq!(WaitForSingleObject(native, INFINITE), 0); //~ ERROR: deadlock: the evaluated program deadlocked
21         }
22     })
23     .join()
24     .unwrap();
25 }