Skip to content

Commit d420f85

Browse files
committed
add test for detaching terminated thread on windows
1 parent 66d19a2 commit d420f85

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@only-target-windows: Uses win32 api functions
2+
// We are making scheduler assumptions here.
3+
//@compile-flags: -Zmiri-preemption-rate=0
4+
5+
use std::os::windows::io::IntoRawHandle;
6+
use std::thread;
7+
8+
extern "system" {
9+
fn CloseHandle(handle: usize) -> i32;
10+
}
11+
12+
fn main() {
13+
let thread = thread::spawn(|| {}).into_raw_handle() as usize;
14+
15+
// this yield ensures that `thread` is terminated by this point
16+
thread::yield_now();
17+
18+
unsafe {
19+
assert_ne!(CloseHandle(thread), 0);
20+
}
21+
}

0 commit comments

Comments
 (0)