rust/tests/fail/concurrency/libc_pthread_join_self.rs
2022-06-01 10:53:38 -04:00

21 lines
481 B
Rust

// ignore-windows: No libc on Windows
// Joining itself is undefined behavior.
#![feature(rustc_private)]
extern crate libc;
use std::{ptr, thread};
fn main() {
let handle = thread::spawn(|| {
unsafe {
let native: libc::pthread_t = libc::pthread_self();
assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join itself
}
});
thread::yield_now();
handle.join().unwrap();
}