Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a5f0a9b

Browse files
committed
Auto merge of rust-lang#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
}

tests/fail/intrinsics/write_bytes_overflow.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
error: Undefined Behavior: overflow computing total size of `write_bytes`
2-
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
2+
--> $DIR/write_bytes_overflow.rs:LL:CC
33
|
4-
LL | write_bytes(dst, val, count)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
4+
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
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::intrinsics::write_bytes::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
11-
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::write_bytes` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
12-
note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
13-
--> $DIR/write_bytes_overflow.rs:LL:CC
14-
|
15-
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
1711

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

tests/fail/weak_memory/racing_mixed_size_read.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
44

5-
#![feature(core_intrinsics)]
6-
7-
use std::sync::atomic::AtomicU32;
85
use std::sync::atomic::Ordering::*;
6+
use std::sync::atomic::{AtomicU16, AtomicU32};
97
use std::thread::spawn;
108

119
fn static_atomic(val: u32) -> &'static AtomicU32 {
@@ -31,8 +29,8 @@ pub fn main() {
3129
let x_ptr = x as *const AtomicU32 as *const u32;
3230
let x_split = split_u32_ptr(x_ptr);
3331
unsafe {
34-
let hi = &(*x_split)[0] as *const u16;
35-
std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping
32+
let hi = x_split as *const u16 as *const AtomicU16;
33+
(*hi).load(Relaxed); //~ ERROR: imperfectly overlapping
3634
}
3735
});
3836

tests/fail/weak_memory/racing_mixed_size_read.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
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
22
--> $DIR/racing_mixed_size_read.rs:LL:CC
33
|
4-
LL | std::intrinsics::atomic_load_relaxed(hi);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
4+
LL | (*hi).load(Relaxed);
5+
| ^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
66
|
77
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
88
= note: backtrace:

tests/pass/weak_memory/extra_cpp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// but doable in safe (at least sound) Rust.
66

77
#![feature(atomic_from_mut)]
8-
#![feature(core_intrinsics)]
98

109
use std::sync::atomic::Ordering::*;
1110
use std::sync::atomic::{AtomicU16, AtomicU32};

tests/pass/weak_memory/extra_cpp_unsafe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// memory model in the future.
88

99
#![feature(atomic_from_mut)]
10-
#![feature(core_intrinsics)]
1110

1211
use std::sync::atomic::AtomicU32;
1312
use std::sync::atomic::Ordering::*;
@@ -27,7 +26,7 @@ fn racing_mixed_atomicity_read() {
2726

2827
let j2 = spawn(move || {
2928
let x_ptr = x as *const AtomicU32 as *const u32;
30-
unsafe { std::intrinsics::atomic_load_relaxed(x_ptr) }
29+
unsafe { x_ptr.read() }
3130
});
3231

3332
let r1 = j1.join().unwrap();

0 commit comments

Comments
 (0)