summaryrefslogtreecommitdiff
path: root/src/tools/miri/tests/fail/concurrency/windows_join_detached.rs
blob: 548ed63534dbd64be3bc3dece48d30bfbf878c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@only-target-windows: Uses win32 api functions
//@error-pattern: Undefined Behavior: trying to join a detached thread

// Joining a detached thread is undefined behavior.

use std::os::windows::io::{AsRawHandle, RawHandle};
use std::thread;

extern "system" {
    fn CloseHandle(handle: RawHandle) -> u32;
}

fn main() {
    let thread = thread::spawn(|| ());

    unsafe {
        assert_ne!(CloseHandle(thread.as_raw_handle()), 0);
    }

    thread.join().unwrap();
}