Skip to content

Commit a5f0a9b

Browse files
committed
Auto merge of #2435 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 8fdb720 + 3ee5698 commit a5f0a9b

15 files changed

+27
-52
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
41419e70366962c9a878bfe673ef4df38db6f7f1
1+
35a061724802377a21fc6dac1ebcbb9b8d1f558a
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Some optimizations remove ZST accesses, thus masking this UB.
22
//@compile-flags: -Zmir-opt-level=0
3-
//@error-pattern: memory access failed: null pointer is a dangling pointer
43

54
#[allow(deref_nullptr)]
65
fn main() {
76
// Not using the () type here, as writes of that type do not even have MIR generated.
87
// Also not assigning directly as that's array initialization, not assignment.
98
let zst_val = [1u8; 0];
109
unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
10+
//~^ERROR: memory access failed: null pointer is a dangling pointer
1111
}

tests/fail/dangling_pointers/null_pointer_write_zst.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
2-
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
2+
--> $DIR/null_pointer_write_zst.rs:LL:CC
33
|
4-
LL | copy_nonoverlapping(&src as *const T, dst, 1);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
4+
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: backtrace:
10-
= note: inside `std::ptr::write::<[u8; 0]>` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
11-
= note: inside `std::ptr::mut_ptr::<impl *mut [u8; 0]>::write` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
12-
note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
13-
--> $DIR/null_pointer_write_zst.rs:LL:CC
14-
|
15-
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
1711

1812
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1913

tests/fail/data_race/atomic_read_na_write_race1.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// We want to control preemption here.
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
4-
#![feature(core_intrinsics)]
54

6-
use std::intrinsics;
7-
use std::sync::atomic::AtomicUsize;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
86
use std::thread::spawn;
97

108
#[derive(Copy, Clone)]
@@ -23,8 +21,7 @@ pub fn main() {
2321
});
2422

2523
let j2 = spawn(move || {
26-
//Equivalent to: (&*c.0).load(Ordering::SeqCst)
27-
intrinsics::atomic_load_seqcst(c.0 as *mut usize) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
24+
(&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
2825
});
2926

3027
j1.join().unwrap();

tests/fail/data_race/atomic_read_na_write_race1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
22
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
33
|
4-
LL | intrinsics::atomic_load_seqcst(c.0 as *mut usize)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
4+
LL | (&*c.0).load(Ordering::SeqCst)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/data_race/atomic_write_na_read_race2.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// We want to control preemption here.
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
4-
#![feature(core_intrinsics)]
54

6-
use std::intrinsics::atomic_store;
7-
use std::sync::atomic::AtomicUsize;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
86
use std::thread::spawn;
97

108
#[derive(Copy, Clone)]
@@ -23,8 +21,7 @@ pub fn main() {
2321
});
2422

2523
let j2 = spawn(move || {
26-
//Equivalent to: (&*c.0).store(32, Ordering::SeqCst)
27-
atomic_store(c.0 as *mut usize, 32); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
24+
(&*c.0).store(32, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
2825
});
2926

3027
j1.join().unwrap();

tests/fail/data_race/atomic_write_na_read_race2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
22
--> $DIR/atomic_write_na_read_race2.rs:LL:CC
33
|
4-
LL | atomic_store(c.0 as *mut usize, 32);
4+
LL | (&*c.0).store(32, Ordering::SeqCst);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior

tests/fail/data_race/atomic_write_na_write_race1.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// We want to control preemption here.
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
4-
#![feature(core_intrinsics)]
54

6-
use std::intrinsics::atomic_store;
7-
use std::sync::atomic::AtomicUsize;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
86
use std::thread::spawn;
97

108
#[derive(Copy, Clone)]
@@ -23,8 +21,7 @@ pub fn main() {
2321
});
2422

2523
let j2 = spawn(move || {
26-
//Equivalent to: (&*c.0).store(64, Ordering::SeqCst)
27-
atomic_store(c.0 as *mut usize, 64); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
24+
(&*c.0).store(64, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
2825
});
2926

3027
j1.join().unwrap();

tests/fail/data_race/atomic_write_na_write_race1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
22
--> $DIR/atomic_write_na_write_race1.rs:LL:CC
33
|
4-
LL | atomic_store(c.0 as *mut usize, 64);
4+
LL | (&*c.0).store(64, Ordering::SeqCst);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//@error-pattern: overflow computing total size of `write_bytes`
21
use std::mem;
32

43
fn main() {
54
let mut y = 0;
65
unsafe {
76
(&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
7+
//~^ ERROR: overflow computing total size of `write_bytes`
88
}
99
}

0 commit comments

Comments
 (0)