rust/tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.rs
Vytautas Astrauskas bd97074517 Small changes.
2020-05-25 00:02:54 +02:00

19 lines
739 B
Rust

// ignore-windows: No libc on Windows
#![feature(rustc_private)]
extern crate libc;
fn main() {
unsafe {
let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
// FIXME: The error should be deadlock. See issue
// https://github.com/rust-lang/miri/issues/1419.
libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR Undefined Behavior
}
}