Skip to content

Show the offset, length and memory of uninit read errors #142673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 18, 2025

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 Spans to. So we'd basically report normal diagnostics for them with squiggly lines and everything.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Comment on lines 666 to 674
throw_ub!(InvalidUninitBytes(None));
throw_ub!(InvalidUninitBytes(match op.to_op(self)?.as_mplace_or_imm() {
Left(mplace) => mplace.ptr().provenance.and_then(|prov| {
let start = mplace.ptr().into_parts().1;
let size = op.layout().size;
let range = alloc_range(start, size);
Some((prov.get_alloc_id()?, BadBytesAccess { access: range, bad: range }))
}),
Right(_) => None,
}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't show up in diagnostics, but it seemed good to change it, too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it show up in diagnostics? Aren't all the miri output diffs caused by exactly this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no, that diff is probably caused by the read_scalar change.

If this logic here can't be tested, I'd rather remove it, given that it is currently wrong due to how it uses into_parts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#142839 gets rid of it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is read_immediate, #142839 does nothing there...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, I mixed up things.

hmm. yea I think I just tried this one because I thought it should be hit somewhere. So I'll turn it into a span_bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, digging into this got more interesting. I added two more commits. TLDR: we only ever use Immediate::Uninit for zsts or for uninit locals. But reading uninit locals only happens by converting them to Operand, which handles uninit immediates if processed by erroring.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's kind of an accidental invariant though, I think... is it worth relying on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It allows some simplifications. lmk what you think about the latest commits and I can either restore the previous zst/uninit design, or we keep it and revisit if we notice there's something better to do with it (or matthias manages to fuzz us examples of how that code is actually reachable for non-zsts)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, looks like mir opts use uninit a lot more, so I backed out that commit

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 18, 2025

grml. I haven't been able to run miri's dep tests in-tree in forever. Always sth about libc not found. Will try to bless the others and hope none of these need blessing

@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the uninit-read-mem branch 2 times, most recently from ff2e26b to 0120c8e Compare June 23, 2025 08:34
Comment on lines 666 to 674
throw_ub!(InvalidUninitBytes(None));
throw_ub!(InvalidUninitBytes(match op.to_op(self)?.as_mplace_or_imm() {
Left(mplace) => mplace.ptr().provenance.and_then(|prov| {
let start = mplace.ptr().into_parts().1;
let size = op.layout().size;
let range = alloc_range(start, size);
Some((prov.get_alloc_id()?, BadBytesAccess { access: range, bad: range }))
}),
Right(_) => None,
}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it show up in diagnostics? Aren't all the miri output diffs caused by exactly this?

throw_ub!(InvalidUninitBytes(None));
throw_ub!(InvalidUninitBytes(match op.to_op(self)?.as_mplace_or_imm() {
Left(mplace) => mplace.ptr().provenance.and_then(|prov| {
let start = mplace.ptr().into_parts().1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct -- depending on which type of provenance this is, start will be either relative to the allocation, or absolute. into_parts has a doc comment warning about this. :) Maybe we should rename it into_raw_parts or so to make it more clear that this API is somewhat dicey.

@bors
Copy link
Collaborator

bors commented Jun 27, 2025

☔ The latest upstream changes (presumably #143091) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 28, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@oli-obk oli-obk force-pushed the uninit-read-mem branch 2 times, most recently from 3abcbd3 to 67c2e92 Compare June 30, 2025 10:32
@rustbot
Copy link
Collaborator

rustbot commented Jun 30, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jun 30, 2025

☔ The latest upstream changes (presumably #142839) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk force-pushed the uninit-read-mem branch from dd800e1 to 6d55968 Compare July 1, 2025 11:13
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 1, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 1, 2025
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
tests/fail/tree_borrows/reserved/int-protected-write.rs ... ok
tests/fail/weak_memory/weak_uninit.rs ... FAILED

FAILED TEST: tests/fail/read_from_trivial_switch.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-6zF5Af" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail" "tests/fail/read_from_trivial_switch.rs" "--edition" "2021"

error: no output was expected
Execute `./miri test --bless` to update `tests/fail/read_from_trivial_switch.64bit.stderr` to the actual output
+++ <stderr output>
error: Undefined Behavior: reading memory at alloc244[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
##[error]  --> tests/fail/read_from_trivial_switch.rs:14:9
   |
LL |     let &(0 | _) = bad_ref;
   |         ^^^^^^^^ Undefined Behavior occurred here
   |
   = 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 `main` at tests/fail/read_from_trivial_switch.rs:14:9: 14:17

Uninitialized memory occurred at alloc244[0x0..0x4], in this allocation:
alloc244 (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



full stderr:
error: Undefined Behavior: reading memory at alloc244[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
##[error]  --> tests/fail/read_from_trivial_switch.rs:14:9
   |
LL |     let &(0 | _) = bad_ref;
   |         ^^^^^^^^ Undefined Behavior occurred here
   |
   = 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 `main` at tests/fail/read_from_trivial_switch.rs:14:9: 14:17

Uninitialized memory occurred at alloc244[0x0..0x4], in this allocation:
alloc244 (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


full stdout:



FAILED TEST: tests/fail/storage-live-resets-var.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-6zF5Af" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail" "tests/fail/storage-live-resets-var.rs" "--edition" "2021"

error: test got exit status: 101, but expected 1
 = note: the compiler panicked

error: actual output differed from expected
---
+thread 'rustc' panicked at /checkout/compiler/rustc_const_eval/src/interpret/operand.rs:LL:CC:
+Box<dyn Any>
+stack backtrace:
+   0: std::panicking::begin_panic
+   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
+   2: <rustc_errors::DiagCtxtHandle>::span_bug
+   3: rustc_middle::util::bug::opt_span_bug_fmt::{closure#0}
+   4: rustc_middle::ty::context::tls::with_opt::{closure#0}
+   5: rustc_middle::ty::context::tls::with_context_opt
+   6: rustc_middle::util::bug::span_bug_fmt
+   7: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine>>::read_immediate
+   8: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine>>::try_visit_primitive
+   9: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<miri::machine::MiriMachine>>::visit_value
+  10: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::validate_operand_internal
+  11: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::eval_rvalue_into_place
+  12: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::concurrency::thread::EvalContextExt>::run_threads
+  13: miri::eval::eval_entry
+  14: <miri::MiriCompilerCalls as rustc_driver_impl::Callbacks>::after_analysis
+  15: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with
+  16: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt
+  17: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
+  18: <alloc::boxed::Box<dyn for<'a> core::ops::function::FnOnce<(&'a rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &'a std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena<'a>>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}), Output = core::option::Option<rustc_interface::queries::Linker>>> as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once
+  19: rustc_interface::passes::create_and_enter_global_ctxt
+  20: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set
+  21: rustc_span::create_session_globals_then
+note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
+
---
+   = note: inside `std::panicking::catch_unwind::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panicking.rs:LL:CC
+   = note: inside `std::panicking::catch_unwind::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC
+   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC
+   = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
+   = note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
+   = note: inside `std::panicking::catch_unwind::<isize, {closure@std::rt::lang_start_internal::{closure#0}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
+   = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
+   = note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
+   = note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
---
thread 'rustc' panicked at /checkout/compiler/rustc_const_eval/src/interpret/operand.rs:668:13:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine>>::read_immediate
   8: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine>>::try_visit_primitive
   9: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<miri::machine::MiriMachine>>::visit_value
  10: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::validate_operand_internal
  11: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::eval_rvalue_into_place
  12: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::concurrency::thread::EvalContextExt>::run_threads
  13: miri::eval::eval_entry
  14: <miri::MiriCompilerCalls as rustc_driver_impl::Callbacks>::after_analysis
  15: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  16: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}>
  17: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  18: <alloc::boxed::Box<dyn for<'a> core::ops::function::FnOnce<(&'a rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &'a std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena<'a>>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}), Output = core::option::Option<rustc_interface::queries::Linker>>> as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once
  19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  20: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  21: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---
   = note: inside `std::panicking::catch_unwind::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /checkout/library/std/src/panicking.rs:589:40: 589:43
   = note: inside `std::panicking::catch_unwind::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /checkout/library/std/src/panicking.rs:552:19: 552:88
   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /checkout/library/std/src/panic.rs:359:14: 359:40
   = note: inside closure at /checkout/library/std/src/rt.rs:175:24: 175:49
   = note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at /checkout/library/std/src/panicking.rs:589:40: 589:43
   = note: inside `std::panicking::catch_unwind::<isize, {closure@std::rt::lang_start_internal::{closure#0}}>` at /checkout/library/std/src/panicking.rs:552:19: 552:88
   = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at /checkout/library/std/src/panic.rs:359:14: 359:40
   = note: inside `std::rt::lang_start_internal` at /checkout/library/std/src/rt.rs:171:5: 193:7
   = note: inside `std::rt::lang_start::<()>` at /checkout/library/std/src/rt.rs:205:5: 210:6

error: aborting due to 1 previous error

---

error: there were 1 unmatched diagnostics
##[error] --> tests/fail/storage-live-resets-var.rs:1:1
  |
1 | #![feature(core_intrinsics, custom_mir)]
  | ^ Ice: /checkout/compiler/rustc_const_eval/src/interpret/operand.rs:668:13: uninit immediate reads should have already errored when reading from memory
  |

full stderr:
##[error]error: internal compiler error: /checkout/compiler/rustc_const_eval/src/interpret/operand.rs:668:13: uninit immediate reads should have already errored when reading from memory


thread 'rustc' panicked at /checkout/compiler/rustc_const_eval/src/interpret/operand.rs:668:13:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine>>::read_immediate
   8: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine>>::try_visit_primitive
   9: <rustc_const_eval::interpret::validity::ValidityVisitor<miri::machine::MiriMachine> as rustc_const_eval::interpret::visitor::ValueVisitor<miri::machine::MiriMachine>>::visit_value
  10: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::validate_operand_internal
  11: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::eval_rvalue_into_place
  12: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::concurrency::thread::EvalContextExt>::run_threads
  13: miri::eval::eval_entry
  14: <miri::MiriCompilerCalls as rustc_driver_impl::Callbacks>::after_analysis
  15: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  16: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}>
  17: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  18: <alloc::boxed::Box<dyn for<'a> core::ops::function::FnOnce<(&'a rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &'a std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena<'a>>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}), Output = core::option::Option<rustc_interface::queries::Linker>>> as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once
  19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  20: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  21: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---
   = note: inside `std::panicking::catch_unwind::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /checkout/library/std/src/panicking.rs:589:40: 589:43
   = note: inside `std::panicking::catch_unwind::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /checkout/library/std/src/panicking.rs:552:19: 552:88
   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /checkout/library/std/src/panic.rs:359:14: 359:40
   = note: inside closure at /checkout/library/std/src/rt.rs:175:24: 175:49
   = note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at /checkout/library/std/src/panicking.rs:589:40: 589:43
   = note: inside `std::panicking::catch_unwind::<isize, {closure@std::rt::lang_start_internal::{closure#0}}>` at /checkout/library/std/src/panicking.rs:552:19: 552:88
   = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at /checkout/library/std/src/panic.rs:359:14: 359:40
   = note: inside `std::rt::lang_start_internal` at /checkout/library/std/src/rt.rs:171:5: 193:7
   = note: inside `std::rt::lang_start::<()>` at /checkout/library/std/src/rt.rs:205:5: 210:6

error: aborting due to 1 previous error


full stdout:



FAILED TEST: tests/fail/weak_memory/weak_uninit.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-6zF5Af" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/weak_memory" "tests/fail/weak_memory/weak_uninit.rs" "-Zmiri-ignore-leaks" "-Zmiri-fixed-schedule" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/weak_memory/weak_uninit.stderr` to the actual output
--- tests/fail/weak_memory/weak_uninit.stderr
+++ <stderr output>
-error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
+error: Undefined Behavior: reading memory at ALLOC[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory
   --> tests/fail/weak_memory/weak_uninit.rs:LL:CC
    |
... 6 lines skipped ...
    = note: inside closure at tests/fail/weak_memory/weak_uninit.rs:LL:CC
 
+Uninitialized memory occurred at ALLOC[0x0..0x8], in this allocation:
+ALLOC (Rust heap, size: 8, align: 8) {
+    01 00 00 00 00 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
 

Full unnormalized output:
error: Undefined Behavior: reading memory at alloc8546[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory
##[error]  --> tests/fail/weak_memory/weak_uninit.rs:31:28
   |
LL |     let j2 = spawn(move || x.load(Ordering::Relaxed));
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
   |
   = 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 on thread `unnamed-6`:
   = note: inside closure at tests/fail/weak_memory/weak_uninit.rs:31:28: 31:53

Uninitialized memory occurred at alloc8546[0x0..0x8], in this allocation:
alloc8546 (Rust heap, size: 8, align: 8) {
    01 00 00 00 00 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



error: `using uninitialized data` not found in diagnostics on line 31
##[error]  --> tests/fail/weak_memory/weak_uninit.rs:31:66
   |
31 |     let j2 = spawn(move || x.load(Ordering::Relaxed)); //~ERROR: using uninitialized data
   |                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
   |

error: there were 1 unmatched diagnostics
##[error]  --> tests/fail/weak_memory/weak_uninit.rs:31:28
   |
31 |     let j2 = spawn(move || x.load(Ordering::Relaxed)); //~ERROR: using uninitialized data
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ Error: Undefined Behavior: reading memory at alloc8546[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory
   |

full stderr:
error: Undefined Behavior: reading memory at alloc8546[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory
##[error]  --> tests/fail/weak_memory/weak_uninit.rs:31:28
   |
LL |     let j2 = spawn(move || x.load(Ordering::Relaxed));
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
   |
   = 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 on thread `unnamed-6`:
   = note: inside closure at tests/fail/weak_memory/weak_uninit.rs:31:28: 31:53

Uninitialized memory occurred at alloc8546[0x0..0x8], in this allocation:
alloc8546 (Rust heap, size: 8, align: 8) {
    01 00 00 00 00 00 00 00                         │ ........
}

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

---

Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.29.2/src/lib.rs:369

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/ui-bc93e79d4a2c7d94` (exit status: 1)
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:48:11
  local time: Tue Jul  1 12:10:49 UTC 2025
  network time: Tue, 01 Jul 2025 12:10:49 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 1, 2025

@rustbot author

Hmm miri validation hits that case apparently

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants