commit
a5f0a9b7ed
@ -1 +1 @@
|
||||
41419e70366962c9a878bfe673ef4df38db6f7f1
|
||||
35a061724802377a21fc6dac1ebcbb9b8d1f558a
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Some optimizations remove ZST accesses, thus masking this UB.
|
||||
//@compile-flags: -Zmir-opt-level=0
|
||||
//@error-pattern: memory access failed: null pointer is a dangling pointer
|
||||
|
||||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
@ -8,4 +7,5 @@ fn main() {
|
||||
// Also not assigning directly as that's array initialization, not assignment.
|
||||
let zst_val = [1u8; 0];
|
||||
unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
||||
//~^ERROR: memory access failed: null pointer is a dangling pointer
|
||||
}
|
||||
|
@ -1,19 +1,13 @@
|
||||
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
|
||||
--> $DIR/null_pointer_write_zst.rs:LL:CC
|
||||
|
|
||||
LL | copy_nonoverlapping(&src as *const T, dst, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
= note: backtrace:
|
||||
= note: inside `std::ptr::write::<[u8; 0]>` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
|
||||
= note: inside `std::ptr::mut_ptr::<impl *mut [u8; 0]>::write` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
|
||||
note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
|
||||
--> $DIR/null_pointer_write_zst.rs:LL:CC
|
||||
|
|
||||
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
// 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)]
|
||||
@ -23,8 +21,7 @@ pub fn main() {
|
||||
});
|
||||
|
||||
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();
|
||||
|
@ -1,8 +1,8 @@
|
||||
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
|
||||
|
@ -1,10 +1,8 @@
|
||||
// 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)]
|
||||
@ -23,8 +21,7 @@ pub fn main() {
|
||||
});
|
||||
|
||||
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();
|
||||
|
@ -1,7 +1,7 @@
|
||||
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
|
||||
|
@ -1,10 +1,8 @@
|
||||
// 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)]
|
||||
@ -23,8 +21,7 @@ pub fn main() {
|
||||
});
|
||||
|
||||
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();
|
||||
|
@ -1,7 +1,7 @@
|
||||
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
|
||||
|
@ -1,9 +1,9 @@
|
||||
//@error-pattern: overflow computing total size of `write_bytes`
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
let mut y = 0;
|
||||
unsafe {
|
||||
(&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||
//~^ ERROR: overflow computing total size of `write_bytes`
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,13 @@
|
||||
error: Undefined Behavior: overflow computing total size of `write_bytes`
|
||||
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
|
||||
--> $DIR/write_bytes_overflow.rs:LL:CC
|
||||
|
|
||||
LL | write_bytes(dst, val, count)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
|
||||
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
|
||||
|
|
||||
= 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
|
||||
= note: backtrace:
|
||||
= note: inside `std::intrinsics::write_bytes::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
|
||||
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::write_bytes` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
|
||||
note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
|
||||
--> $DIR/write_bytes_overflow.rs:LL:CC
|
||||
|
|
||||
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
|
@ -2,10 +2,8 @@
|
||||
//@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 {
|
||||
@ -31,8 +29,8 @@ pub fn main() {
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
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:
|
||||
|
@ -5,7 +5,6 @@
|
||||
// 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};
|
||||
|
@ -7,7 +7,6 @@
|
||||
// memory model in the future.
|
||||
|
||||
#![feature(atomic_from_mut)]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::sync::atomic::AtomicU32;
|
||||
use std::sync::atomic::Ordering::*;
|
||||
@ -27,7 +26,7 @@ fn racing_mixed_atomicity_read() {
|
||||
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user