Rollup merge of #142673 - oli-obk:uninit-read-mem, r=RalfJung
Show the offset, length and memory of uninit read errors r? ``@RalfJung`` I want to improve memory dumps in general. Not sure yet how to do so best within rust diagnostics, but in a perfect world I could generate a dummy in-memory file (that contains the rendered memory dump) that we then can then provide regular rustc `Span`s to. So we'd basically report normal diagnostics for them with squiggly lines and everything.
This commit is contained in:
commit
b3827e4f37
63 changed files with 402 additions and 144 deletions
|
|
@ -1,4 +1,6 @@
|
|||
//@ignore-target: windows # No pthreads on Windows
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
/// Test that destroying a pthread_cond twice fails, even without a check for number validity
|
||||
|
||||
|
|
@ -15,6 +17,6 @@ fn main() {
|
|||
libc::pthread_cond_destroy(cond.as_mut_ptr());
|
||||
|
||||
libc::pthread_cond_destroy(cond.as_mut_ptr());
|
||||
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
|
||||
|
|
||||
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
|
||||
|
|
@ -9,6 +9,9 @@ LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
//@ignore-target: windows # No pthreads on Windows
|
||||
//@ignore-target: apple # Our macOS condattr don't have any fields so we do not notice this.
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
/// Test that destroying a pthread_condattr twice fails, even without a check for number validity
|
||||
|
||||
|
|
@ -13,6 +15,6 @@ fn main() {
|
|||
libc::pthread_condattr_destroy(attr.as_mut_ptr());
|
||||
|
||||
libc::pthread_condattr_destroy(attr.as_mut_ptr());
|
||||
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
|
||||
|
|
||||
LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
|
||||
|
|
@ -9,6 +9,9 @@ LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//@ignore-target: windows # No pthreads on Windows
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
/// Test that destroying a pthread_mutex twice fails, even without a check for number validity
|
||||
|
||||
|
|
@ -16,6 +18,6 @@ fn main() {
|
|||
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
|
||||
|
||||
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
|
||||
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
|
||||
|
|
||||
LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
|
||||
|
|
@ -9,6 +9,9 @@ LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//@ignore-target: windows # No pthreads on Windows
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity
|
||||
|
||||
|
|
@ -12,6 +14,6 @@ fn main() {
|
|||
libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
|
||||
|
||||
libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
|
||||
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs:LL:CC
|
||||
|
|
||||
LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
|
||||
|
|
@ -9,6 +9,9 @@ LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//@ignore-target: windows # No pthreads on Windows
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity
|
||||
|
||||
|
|
@ -9,6 +11,6 @@ fn main() {
|
|||
libc::pthread_rwlock_destroy(&mut lock);
|
||||
|
||||
libc::pthread_rwlock_destroy(&mut lock);
|
||||
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
|
||||
|
|
||||
LL | libc::pthread_rwlock_destroy(&mut lock);
|
||||
|
|
@ -9,6 +9,9 @@ LL | libc::pthread_rwlock_destroy(&mut lock);
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
|
||||
--> tests/fail/function_calls/arg_inplace_observe_after.rs:LL:CC
|
||||
|
|
||||
LL | _observe = non_copy.0;
|
||||
|
|
@ -9,6 +9,11 @@ LL | _observe = non_copy.0;
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/function_calls/arg_inplace_observe_after.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
|
||||
ALLOC (stack variable, size: 4, align: 4) {
|
||||
__ __ __ __ │ ░░░░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
|
||||
--> tests/fail/function_calls/arg_inplace_observe_during.rs:LL:CC
|
||||
|
|
||||
LL | unsafe { ptr.read() };
|
||||
|
|
@ -14,6 +14,11 @@ note: inside `main`
|
|||
LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
|
||||
ALLOC (stack variable, size: 4, align: 4) {
|
||||
__ __ __ __ │ ░░░░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
|
||||
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
|
||||
|
|
||||
LL | unsafe { ptr.read() };
|
||||
|
|
@ -14,6 +14,11 @@ note: inside `main`
|
|||
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
|
||||
ALLOC (stack variable, size: 4, align: 4) {
|
||||
__ __ __ __ │ ░░░░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ thread 'main' panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:
|
|||
explicit panic
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
|
||||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
|
||||
--> tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC
|
||||
|
|
||||
LL | dbg!(x.0);
|
||||
|
|
@ -15,6 +15,19 @@ LL | dbg!(x.0);
|
|||
= note: inside `main` at RUSTLIB/std/src/macros.rs:LL:CC
|
||||
= note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
|
||||
ALLOC (stack variable, size: 132, align: 4) {
|
||||
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x30 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x40 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x50 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x60 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x70 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
|
||||
0x80 │ __ __ __ __ │ ░░░░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
//@compile-flags: -Zmiri-disable-validation
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
#![feature(core_intrinsics, custom_mir)]
|
||||
use std::intrinsics::mir::*;
|
||||
|
||||
|
|
@ -9,7 +12,7 @@ use std::intrinsics::mir::*;
|
|||
pub unsafe fn deref_meta(p: *const *const [i32]) -> usize {
|
||||
mir! {
|
||||
{
|
||||
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
|
||||
RET = PtrMetadata(*p); //~ ERROR: /Undefined Behavior: .* but memory is uninitialized/
|
||||
Return()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/intrinsics/ptr_metadata_uninit_slice_data.rs:LL:CC
|
||||
|
|
||||
LL | RET = PtrMetadata(*p);
|
||||
|
|
@ -14,6 +14,9 @@ note: inside `main`
|
|||
LL | let _meta = deref_meta(p.as_ptr().cast());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
//@compile-flags: -Zmiri-disable-validation
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]+..0x[0-9a-z]+\]" -> "[0xX..0xY]"
|
||||
|
||||
#![feature(core_intrinsics, custom_mir)]
|
||||
use std::intrinsics::mir::*;
|
||||
|
||||
|
|
@ -9,7 +12,7 @@ use std::intrinsics::mir::*;
|
|||
pub unsafe fn deref_meta(p: *const *const [i32]) -> usize {
|
||||
mir! {
|
||||
{
|
||||
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
|
||||
RET = PtrMetadata(*p); //~ ERROR: /Undefined Behavior: .* but memory is uninitialized/
|
||||
Return()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LL | (*p.as_mut_ptr().cast::<[*const i32; 2]>())[0] = 4 as *const i32;
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/intrinsics/ptr_metadata_uninit_slice_len.rs:LL:CC
|
||||
|
||||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/intrinsics/ptr_metadata_uninit_slice_len.rs:LL:CC
|
||||
|
|
||||
LL | RET = PtrMetadata(*p);
|
||||
|
|
@ -28,6 +28,9 @@ note: inside `main`
|
|||
LL | let _meta = deref_meta(p.as_ptr().cast());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
//@compile-flags: -Zmiri-disable-validation
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
#![feature(core_intrinsics, custom_mir)]
|
||||
use std::intrinsics::mir::*;
|
||||
|
||||
|
|
@ -9,7 +12,7 @@ use std::intrinsics::mir::*;
|
|||
pub unsafe fn deref_meta(p: *const *const i32) -> () {
|
||||
mir! {
|
||||
{
|
||||
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
|
||||
RET = PtrMetadata(*p); //~ ERROR: /Undefined Behavior: .*, but memory is uninitialized/
|
||||
Return()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/intrinsics/ptr_metadata_uninit_thin.rs:LL:CC
|
||||
|
|
||||
LL | RET = PtrMetadata(*p);
|
||||
|
|
@ -14,6 +14,9 @@ note: inside `main`
|
|||
LL | let _meta = deref_meta(p.as_ptr());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@
|
|||
//
|
||||
// See <https://github.com/rust-lang/miri/issues/4237>.
|
||||
|
||||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
fn main() {
|
||||
let uninit: MaybeUninit<i32> = MaybeUninit::uninit();
|
||||
let bad_ref: &i32 = unsafe { uninit.assume_init_ref() };
|
||||
let &(0 | _) = bad_ref;
|
||||
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
//~^ ERROR: /Undefined Behavior: .*, but memory is uninitialized .* requires initialized memory/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/read_from_trivial_switch.rs:LL:CC
|
||||
|
|
||||
LL | let &(0 | _) = bad_ref;
|
||||
|
|
@ -9,6 +9,9 @@ LL | let &(0 | _) = bad_ref;
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/read_from_trivial_switch.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
use std::mem;
|
||||
|
||||
// We have three fields to avoid the ScalarPair optimization.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/uninit/padding-enum.rs:LL:CC
|
||||
|
|
||||
LL | let _val = *c.add(padding_offset);
|
||||
|
|
@ -9,6 +9,9 @@ LL | let _val = *c.add(padding_offset);
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/uninit/padding-enum.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::mem::{self, MaybeUninit};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/uninit/padding-pair.rs:LL:CC
|
||||
|
|
||||
LL | let v = unsafe { *z.offset(first_undef) };
|
||||
|
|
@ -9,6 +9,9 @@ LL | let v = unsafe { *z.offset(first_undef) };
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/uninit/padding-pair.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
|
||||
--> tests/fail/uninit/padding-struct.rs:LL:CC
|
||||
|
|
||||
LL | let _val = *c.add(1);
|
||||
|
|
@ -9,6 +9,11 @@ LL | let _val = *c.add(1);
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/uninit/padding-struct.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x1..0x2], in this allocation:
|
||||
ALLOC (stack variable, size: 4, align: 2) {
|
||||
00 __ 00 00 │ .░..
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
use std::mem;
|
||||
|
||||
// If this is `None`, the metadata becomes padding.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/uninit/padding-wide-ptr.rs:LL:CC
|
||||
|
|
||||
LL | let _val = *c.add(mem::size_of::<*const u8>());
|
||||
|
|
@ -9,6 +9,9 @@ LL | let _val = *c.add(mem::size_of::<*const u8>());
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/uninit/padding-wide-ptr.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
|
||||
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::mem::{self, MaybeUninit};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
|
||||
--> tests/fail/uninit/transmute-pair-uninit.rs:LL:CC
|
||||
|
|
||||
LL | let v = unsafe { *z.offset(first_undef) };
|
||||
|
|
@ -9,6 +9,9 @@ LL | let v = unsafe { *z.offset(first_undef) };
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/uninit/transmute-pair-uninit.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
|
||||
ALLOC DUMP
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x5..0x6], but memory is uninitialized at [0x5..0x6], and this operation requires initialized memory
|
||||
--> tests/fail/uninit/uninit_byte_read.rs:LL:CC
|
||||
|
|
||||
LL | let undef = unsafe { *v.as_ptr().add(5) };
|
||||
|
|
@ -9,6 +9,11 @@ LL | let undef = unsafe { *v.as_ptr().add(5) };
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/uninit/uninit_byte_read.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x5..0x6], in this allocation:
|
||||
ALLOC (Rust heap, size: 10, align: 1) {
|
||||
__ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
|
||||
--> tests/fail/validity/invalid_int_op.rs:LL:CC
|
||||
|
|
||||
LL | let i = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
|
||||
|
|
@ -9,6 +9,11 @@ LL | let i = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() }
|
|||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail/validity/invalid_int_op.rs:LL:CC
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
|
||||
ALLOC (stack variable, size: 4, align: 4) {
|
||||
__ __ __ __ │ ░░░░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ fn partial_init() {
|
|||
assert!(*slice_ptr == 0);
|
||||
assert!(*slice_ptr.offset(1) == 0);
|
||||
// Reading the third is UB!
|
||||
let _val = *slice_ptr.offset(2); //~ ERROR: Undefined Behavior: using uninitialized data
|
||||
let _val = *slice_ptr.offset(2); //~ ERROR: /Undefined Behavior: reading memory.*, but memory is uninitialized/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ note: inside `main`
|
|||
LL | partial_init();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||
error: Undefined Behavior: reading memory at ALLOC[0x2..0x3], but memory is uninitialized at [0x2..0x3], and this operation requires initialized memory
|
||||
--> tests/native-lib/fail/tracing/partial_init.rs:LL:CC
|
||||
|
|
||||
LL | let _val = *slice_ptr.offset(2);
|
||||
|
|
@ -33,6 +33,11 @@ note: inside `main`
|
|||
LL | partial_init();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
Uninitialized memory occurred at ALLOC[0x2..0x3], in this allocation:
|
||||
ALLOC (stack variable, size: 3, align: 1) {
|
||||
╾00[wildcard] (1 ptr byte)╼ ╾00[wildcard] (1 ptr byte)╼ __ │ ━━░
|
||||
}
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue