]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/windows_join_detached.rs
Auto merge of #98483 - dvtkrlbs:bootstrap-dist, r=jyn514
[rust.git] / src / tools / miri / tests / fail / concurrency / windows_join_detached.rs
1 //@only-target-windows: Uses win32 api functions
2 //@error-pattern: Undefined Behavior: trying to join a detached thread
3
4 // Joining a detached thread is undefined behavior.
5
6 use std::os::windows::io::{AsRawHandle, RawHandle};
7 use std::thread;
8
9 extern "system" {
10     fn CloseHandle(handle: RawHandle) -> u32;
11 }
12
13 fn main() {
14     let thread = thread::spawn(|| ());
15
16     unsafe {
17         assert_ne!(CloseHandle(thread.as_raw_handle()), 0);
18     }
19
20     thread.join().unwrap();
21 }