2022-07-17 20:54:10 -05:00
|
|
|
//@ignore-target-windows: No libc on Windows
|
2022-06-06 16:44:16 -05:00
|
|
|
// 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
|
|
|
}
|