rust/tests/fail/concurrency/libc_pthread_join_self.rs

21 lines
481 B
Rust
Raw Normal View History

2020-06-28 04:31:34 -05:00
// ignore-windows: No libc on Windows
2020-04-19 18:42:58 -05:00
// Joining itself is undefined behavior.
#![feature(rustc_private)]
extern crate libc;
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
}