// We want to control preemption here. //@compile-flags: -Zmiri-preemption-rate=0 //@ignore-target-windows: Concurrency on Windows is not supported yet. use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); unsafe impl Send for EvilSend {} unsafe impl Sync for EvilSend {} extern "Rust" { fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize); } pub fn main() { // Shared atomic pointer let pointer: *mut usize = Box::into_raw(Box::new(0usize)); let ptr = EvilSend(pointer); unsafe { let j1 = spawn(move || { let _val = *ptr.0; }); let j2 = spawn(move || { __rust_dealloc( //~^ ERROR: Data race detected between Deallocate on thread `` and Read on thread `` ptr.0 as *mut _, std::mem::size_of::(), std::mem::align_of::(), ); }); j1.join().unwrap(); j2.join().unwrap(); } }