You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//! This is a regression test for <https://github.com/rust-lang/miri/issues/3947>: we had some
2
+
//! faulty logic around `release_clock` that led to this code not reporting a data race.
3
+
//@ignore-target: windows # no libc socketpair on Windows
4
+
//@compile-flags: -Zmiri-preemption-rate=0
5
+
use std::thread;
6
+
7
+
fnmain(){
8
+
staticmutVAL:u8 = 0;
9
+
letmut fds = [-1, -1];
10
+
let res = unsafe{ libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM,0, fds.as_mut_ptr())};
11
+
assert_eq!(res,0);
12
+
let thread1 = thread::spawn(move || {
13
+
let data = "a".as_bytes().as_ptr();
14
+
let res = unsafe{ libc::write(fds[0], data as*const libc::c_void,1)};
15
+
assert_eq!(res,1);
16
+
// The write to VAL is *after* the write to the socket, so there's no proper synchronization.
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) non-atomic read on thread `main` at ALLOC. (2) just happened here
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
15
+
= note: inside `main` at tests/fail-dep/libc/socketpair-data-race.rs:LL:CC
16
+
17
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
0 commit comments