Skip to content

Commit 0120c8e

Browse files
committed
Show the memory of uninit reads
1 parent 8b226a6 commit 0120c8e

File tree

59 files changed

+454
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+454
-113
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ use std::mem;
22

33
use rustc_errors::{Diag, DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg};
44
use rustc_middle::mir::AssertKind;
5-
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo};
5+
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo, UndefinedBehaviorInfo};
66
use rustc_middle::query::TyCtxtAt;
7+
use rustc_middle::ty::ConstInt;
78
use rustc_middle::ty::layout::LayoutError;
8-
use rustc_middle::ty::{ConstInt, TyCtxt};
99
use rustc_span::{Span, Symbol};
1010

1111
use super::CompileTimeMachine;
1212
use crate::errors::{self, FrameNote, ReportErrorExt};
1313
use crate::interpret::{
14-
ErrorHandled, Frame, InterpErrorInfo, InterpErrorKind, MachineStopType, err_inval,
14+
ErrorHandled, Frame, InterpCx, InterpErrorInfo, InterpErrorKind, MachineStopType, err_inval,
1515
err_machine_stop,
1616
};
1717

@@ -135,7 +135,7 @@ pub fn get_span_and_frames<'tcx>(
135135
/// You can use it to add a stacktrace of current execution according to
136136
/// `get_span_and_frames` or just give context on where the const eval error happened.
137137
pub(super) fn report<'tcx, C, F>(
138-
tcx: TyCtxt<'tcx>,
138+
ecx: &InterpCx<'tcx, CompileTimeMachine<'tcx>>,
139139
error: InterpErrorKind<'tcx>,
140140
span: Span,
141141
get_span_and_frames: C,
@@ -145,6 +145,7 @@ where
145145
C: FnOnce() -> (Span, Vec<FrameNote>),
146146
F: FnOnce(&mut Diag<'_>, Span, Vec<FrameNote>),
147147
{
148+
let tcx = ecx.tcx.tcx;
148149
// Special handling for certain errors
149150
match error {
150151
// Don't emit a new diagnostic for these errors, they are already reported elsewhere or
@@ -170,9 +171,24 @@ where
170171
InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_)
171172
);
172173

174+
if let InterpErrorKind::UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(
175+
Some((alloc_id, _access)),
176+
)) = error
177+
{
178+
let bytes = ecx.print_alloc_bytes_for_diagnostics(alloc_id);
179+
let info = ecx.get_alloc_info(alloc_id);
180+
let raw_bytes = errors::RawBytesNote {
181+
size: info.size.bytes(),
182+
align: info.align.bytes(),
183+
bytes,
184+
};
185+
err.subdiagnostic(raw_bytes);
186+
}
187+
173188
error.add_args(&mut err);
174189

175190
mk(&mut err, span, frames);
191+
176192
let g = err.emit();
177193
let reported = if allowed_in_infallible {
178194
ReportedErrorInfo::allowed_in_infallible(g)

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
293293

294294
// FIXME(oli-obk): why don't we have any tests for this code path?
295295
super::report(
296-
tcx,
296+
&InterpCx::new(
297+
tcx,
298+
tcx.def_span(def_id),
299+
key.typing_env,
300+
CompileTimeMachine::new(CanAccessMutGlobal::Yes, CheckAlignment::No),
301+
),
297302
error.into_kind(),
298303
span,
299304
|| (span, vec![]),
@@ -433,7 +438,7 @@ fn report_eval_error<'tcx>(
433438
let instance = with_no_trimmed_paths!(cid.instance.to_string());
434439

435440
super::report(
436-
*ecx.tcx,
441+
ecx,
437442
error,
438443
DUMMY_SP,
439444
|| super::get_span_and_frames(ecx.tcx, ecx.stack()),
@@ -473,7 +478,7 @@ fn report_validation_error<'tcx>(
473478
errors::RawBytesNote { size: info.size.bytes(), align: info.align.bytes(), bytes };
474479

475480
crate::const_eval::report(
476-
*ecx.tcx,
481+
ecx,
477482
error,
478483
DUMMY_SP,
479484
|| crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()),

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ normalize-stderr-test: ".*│.*\n" -> ""
3+
//@ normalize-stderr-test: "size: [0-9]+" -> "size: SIZE"
4+
//@ normalize-stderr-test: "align: [0-9]+" -> "align: ALIGN"
5+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
26

37
/// Test that destroying a pthread_cond twice fails, even without a check for number validity
48
@@ -15,6 +19,6 @@ fn main() {
1519
libc::pthread_cond_destroy(cond.as_mut_ptr());
1620

1721
libc::pthread_cond_destroy(cond.as_mut_ptr());
18-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
22+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1923
}
2024
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
@@ -9,6 +9,10 @@ LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC (stack variable, size: SIZE, align: ALIGN) {
14+
}
15+
1216
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1317

1418
error: aborting due to 1 previous error

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//@ignore-target: windows # No pthreads on Windows
22
//@ignore-target: apple # Our macOS condattr don't have any fields so we do not notice this.
3+
//@ normalize-stderr-test: ".*│.*\n" -> ""
4+
//@ normalize-stderr-test: "size: [0-9]+" -> "size: SIZE"
5+
//@ normalize-stderr-test: "align: [0-9]+" -> "align: ALIGN"
6+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
37

48
/// Test that destroying a pthread_condattr twice fails, even without a check for number validity
59
@@ -13,6 +17,6 @@ fn main() {
1317
libc::pthread_condattr_destroy(attr.as_mut_ptr());
1418

1519
libc::pthread_condattr_destroy(attr.as_mut_ptr());
16-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
20+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1721
}
1822
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
@@ -9,6 +9,10 @@ LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC (stack variable, size: SIZE, align: ALIGN) {
14+
}
15+
1216
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1317

1418
error: aborting due to 1 previous error

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ normalize-stderr-test: ".*│.*\n" -> ""
3+
//@ normalize-stderr-test: "size: [0-9]+" -> "size: SIZE"
4+
//@ normalize-stderr-test: "align: [0-9]+" -> "align: ALIGN"
5+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
26

37
/// Test that destroying a pthread_mutex twice fails, even without a check for number validity
48
@@ -16,6 +20,6 @@ fn main() {
1620
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
1721

1822
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
19-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
23+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
2024
}
2125
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
@@ -9,6 +9,10 @@ LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC (stack variable, size: SIZE, align: ALIGN) {
14+
}
15+
1216
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1317

1418
error: aborting due to 1 previous error

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ normalize-stderr-test: ".*│.*\n" -> ""
3+
//@ normalize-stderr-test: "size: [0-9]+" -> "size: SIZE"
4+
//@ normalize-stderr-test: "align: [0-9]+" -> "align: ALIGN"
5+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
26

37
/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity
48
@@ -12,6 +16,6 @@ fn main() {
1216
libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
1317

1418
libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
15-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
19+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1620
}
1721
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
@@ -9,6 +9,10 @@ LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC (stack variable, size: SIZE, align: ALIGN) {
14+
}
15+
1216
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1317

1418
error: aborting due to 1 previous error

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ normalize-stderr-test: ".*│.*\n" -> ""
3+
//@ normalize-stderr-test: "size: [0-9]+" -> "size: SIZE"
4+
//@ normalize-stderr-test: "align: [0-9]+" -> "align: ALIGN"
5+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
26

37
/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity
48
@@ -9,6 +13,6 @@ fn main() {
913
libc::pthread_rwlock_destroy(&mut lock);
1014

1115
libc::pthread_rwlock_destroy(&mut lock);
12-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
16+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1317
}
1418
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_rwlock_destroy(&mut lock);
@@ -9,6 +9,10 @@ LL | libc::pthread_rwlock_destroy(&mut lock);
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC (stack variable, size: SIZE, align: ALIGN) {
14+
}
15+
1216
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1317

1418
error: aborting due to 1 previous error

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_after.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail/function_calls/arg_inplace_observe_after.rs:LL:CC
33
|
44
LL | _observe = non_copy.0;
@@ -9,6 +9,11 @@ LL | _observe = non_copy.0;
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail/function_calls/arg_inplace_observe_after.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 4, align: 4) {
14+
__ __ __ __ │ ░░░░
15+
}
16+
1217
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1318

1419
error: aborting due to 1 previous error

src/tools/miri/tests/fail/function_calls/arg_inplace_observe_during.none.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail/function_calls/arg_inplace_observe_during.rs:LL:CC
33
|
44
LL | unsafe { ptr.read() };
@@ -14,6 +14,11 @@ note: inside `main`
1414
LL | Call(_unit = change_arg(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue())
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

17+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
18+
ALLOC (stack variable, size: 4, align: 4) {
19+
__ __ __ __ │ ░░░░
20+
}
21+
1722
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1823

1924
error: aborting due to 1 previous error

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing_read.none.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail/function_calls/return_pointer_aliasing_read.rs:LL:CC
33
|
44
LL | unsafe { ptr.read() };
@@ -14,6 +14,11 @@ note: inside `main`
1414
LL | Call(*ptr = myfun(ptr), ReturnTo(after_call), UnwindContinue())
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

17+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
18+
ALLOC (stack variable, size: 4, align: 4) {
19+
__ __ __ __ │ ░░░░
20+
}
21+
1722
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1823

1924
error: aborting due to 1 previous error

src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ thread 'main' panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
6-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
6+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
77
--> tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC
88
|
99
LL | dbg!(x.0);
@@ -15,6 +15,19 @@ LL | dbg!(x.0);
1515
= note: inside `main` at RUSTLIB/std/src/macros.rs:LL:CC
1616
= note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
1717

18+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
19+
ALLOC (stack variable, size: 132, align: 4) {
20+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
21+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
22+
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
23+
0x30 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
24+
0x40 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
25+
0x50 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
26+
0x60 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
27+
0x70 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
28+
0x80 │ __ __ __ __ │ ░░░░
29+
}
30+
1831
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1932

2033
error: aborting due to 1 previous error

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_slice_data.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
//@compile-flags: -Zmiri-disable-validation
2+
//@ normalize-stderr-test: ".*│.*\n" -> ""
3+
//@ normalize-stderr-test: "size: [0-9]+" -> "size: SIZE"
4+
//@ normalize-stderr-test: "align: [0-9]+" -> "align: ALIGN"
5+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
6+
27
#![feature(core_intrinsics, custom_mir)]
38
use std::intrinsics::mir::*;
49

@@ -9,7 +14,7 @@ use std::intrinsics::mir::*;
914
pub unsafe fn deref_meta(p: *const *const [i32]) -> usize {
1015
mir! {
1116
{
12-
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
17+
RET = PtrMetadata(*p); //~ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1318
Return()
1419
}
1520
}

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_slice_data.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail/intrinsics/ptr_metadata_uninit_slice_data.rs:LL:CC
33
|
44
LL | RET = PtrMetadata(*p);
@@ -14,6 +14,10 @@ note: inside `main`
1414
LL | let _meta = deref_meta(p.as_ptr().cast());
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

17+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
18+
ALLOC (stack variable, size: SIZE, align: ALIGN) {
19+
}
20+
1721
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1822

1923
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)