// We want to control preemption here.
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
-#![feature(core_intrinsics)]
-use std::intrinsics;
-use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
});
let j2 = spawn(move || {
- //Equivalent to: (&*c.0).load(Ordering::SeqCst)
- intrinsics::atomic_load_seqcst(c.0 as *mut usize) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
+ (&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
});
j1.join().unwrap();
error: Undefined Behavior: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
|
-LL | intrinsics::atomic_load_seqcst(c.0 as *mut usize)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
+LL | (&*c.0).load(Ordering::SeqCst)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
// We want to control preemption here.
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
-#![feature(core_intrinsics)]
-use std::intrinsics::atomic_store;
-use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
});
let j2 = spawn(move || {
- //Equivalent to: (&*c.0).store(32, Ordering::SeqCst)
- atomic_store(c.0 as *mut usize, 32); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
+ (&*c.0).store(32, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
});
j1.join().unwrap();
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
--> $DIR/atomic_write_na_read_race2.rs:LL:CC
|
-LL | atomic_store(c.0 as *mut usize, 32);
+LL | (&*c.0).store(32, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
// We want to control preemption here.
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
-#![feature(core_intrinsics)]
-use std::intrinsics::atomic_store;
-use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
});
let j2 = spawn(move || {
- //Equivalent to: (&*c.0).store(64, Ordering::SeqCst)
- atomic_store(c.0 as *mut usize, 64); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
+ (&*c.0).store(64, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
});
j1.join().unwrap();
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
--> $DIR/atomic_write_na_write_race1.rs:LL:CC
|
-LL | atomic_store(c.0 as *mut usize, 64);
+LL | (&*c.0).store(64, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
-#![feature(core_intrinsics)]
-
-use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering::*;
+use std::sync::atomic::{AtomicU16, AtomicU32};
use std::thread::spawn;
fn static_atomic(val: u32) -> &'static AtomicU32 {
let x_ptr = x as *const AtomicU32 as *const u32;
let x_split = split_u32_ptr(x_ptr);
unsafe {
- let hi = &(*x_split)[0] as *const u16;
- std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping
+ let hi = x_split as *const u16 as *const AtomicU16;
+ (*hi).load(Relaxed); //~ ERROR: imperfectly overlapping
}
});
error: unsupported operation: racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
--> $DIR/racing_mixed_size_read.rs:LL:CC
|
-LL | std::intrinsics::atomic_load_relaxed(hi);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
+LL | (*hi).load(Relaxed);
+ | ^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: backtrace:
// but doable in safe (at least sound) Rust.
#![feature(atomic_from_mut)]
-#![feature(core_intrinsics)]
use std::sync::atomic::Ordering::*;
use std::sync::atomic::{AtomicU16, AtomicU32};
// memory model in the future.
#![feature(atomic_from_mut)]
-#![feature(core_intrinsics)]
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering::*;
let j2 = spawn(move || {
let x_ptr = x as *const AtomicU32 as *const u32;
- unsafe { std::intrinsics::atomic_load_relaxed(x_ptr) }
+ unsafe { x_ptr.read() }
});
let r1 = j1.join().unwrap();