]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs
Auto merge of #101030 - woppopo:const_location, r=scottmcm
[rust.git] / src / tools / miri / tests / fail / concurrency / libc_pthread_join_main.rs
1 //@ignore-target-windows: No libc on Windows
2
3 // Joining the main thread is undefined behavior.
4
5 use std::{ptr, thread};
6
7 fn main() {
8     let thread_id: libc::pthread_t = unsafe { libc::pthread_self() };
9     let handle = thread::spawn(move || {
10         unsafe {
11             assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread
12         }
13     });
14     thread::yield_now();
15     handle.join().unwrap();
16 }