rust/tests/fail/concurrency/libc_pthread_join_self.rs

19 lines
528 B
Rust
Raw Normal View History

//@ignore-target-windows: No libc on Windows
// We are making scheduler assumptions here.
2022-07-08 11:08:32 -05:00
//@compile-flags: -Zmiri-preemption-rate=0
2020-04-19 18:42:58 -05:00
// Joining itself is undefined behavior.
2020-04-20 15:22:28 -05:00
use std::{ptr, thread};
2020-04-19 18:42:58 -05:00
fn main() {
2020-04-20 15:22:28 -05:00
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();
2020-04-19 18:42:58 -05:00
}