From c33fc24566da5e342e03183c07314c910b690d25 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 24 Jul 2022 08:37:29 -0400 Subject: [PATCH] rustup --- rust-version | 2 +- .../dangling_pointers/null_pointer_write_zst.rs | 2 +- .../null_pointer_write_zst.stderr | 14 ++++---------- tests/fail/intrinsics/write_bytes_overflow.rs | 2 +- tests/fail/intrinsics/write_bytes_overflow.stderr | 14 ++++---------- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/rust-version b/rust-version index b54ff9e100ed..c710735735c7 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -41419e70366962c9a878bfe673ef4df38db6f7f1 +35a061724802377a21fc6dac1ebcbb9b8d1f558a diff --git a/tests/fail/dangling_pointers/null_pointer_write_zst.rs b/tests/fail/dangling_pointers/null_pointer_write_zst.rs index 7181a5979b44..c00344b6de23 100644 --- a/tests/fail/dangling_pointers/null_pointer_write_zst.rs +++ b/tests/fail/dangling_pointers/null_pointer_write_zst.rs @@ -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 } diff --git a/tests/fail/dangling_pointers/null_pointer_write_zst.stderr b/tests/fail/dangling_pointers/null_pointer_write_zst.stderr index 0535aaa3e2d1..17ac04a706ff 100644 --- a/tests/fail/dangling_pointers/null_pointer_write_zst.stderr +++ b/tests/fail/dangling_pointers/null_pointer_write_zst.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/write_bytes_overflow.rs b/tests/fail/intrinsics/write_bytes_overflow.rs index 5c49dc00165c..08bc096d6c36 100644 --- a/tests/fail/intrinsics/write_bytes_overflow.rs +++ b/tests/fail/intrinsics/write_bytes_overflow.rs @@ -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::() * 8 - 1)); + //~^ ERROR: overflow computing total size of `write_bytes` } } diff --git a/tests/fail/intrinsics/write_bytes_overflow.stderr b/tests/fail/intrinsics/write_bytes_overflow.stderr index 1e5381279529..47610b062301 100644 --- a/tests/fail/intrinsics/write_bytes_overflow.stderr +++ b/tests/fail/intrinsics/write_bytes_overflow.stderr @@ -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::() * 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::` at RUSTLIB/core/src/intrinsics.rs:LL:CC - = note: inside `std::ptr::mut_ptr::::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::() * 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