-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)Area: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
auto-reduced (treereduce-rust):
//@compile-flags: -Zmir-opt-level=5
use std::mem::MaybeUninit;
const N: usize = 0x0000_7ff0_0000_0000;
pub fn g(n: &u8) {
let mut xs = MaybeUninit::<[u8; N]>::uninit();
}
pub fn main() {
let n = Box::new(27);
g(&n);
}original:
#![feature(maybe_uninit_as_bytes)]
use std::mem::MaybeUninit;
use std::ptr::from_ref;
const N: usize = 0x0000_7ff0_0000_0000;
#[inline(never)]
pub fn g(n: &u8) {
let mut xs = MaybeUninit::<[u8; N]>::uninit();
let base = from_ref(&xs.as_bytes()[0]).addr();
let index = from_ref(n).addr() - base;
xs.as_bytes_mut()[index].write(42);
}
pub fn main() {
let n = Box::new(27);
g(&n);
std::process::exit(*n as i32);
}Version information
rustc 1.93.0-nightly (b1b08cdef 2025-12-04)
binary: rustc
commit-hash: b1b08cdef5ed3bca71c0d6638fccadc90d2e0ea3
commit-date: 2025-12-04
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5
Program output
warning: variable does not need to be mutable
--> /tmp/icemaker_global_tempdir.55XT4UoLqfnF/rustc_testrunner_tmpdir_reporting.U6y4tz4UTGSn/mvce.rs:6:9
|
6 | let mut xs = MaybeUninit::<[u8; N]>::uninit();
| ----^^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default
warning: unused variable: `n`
--> /tmp/icemaker_global_tempdir.55XT4UoLqfnF/rustc_testrunner_tmpdir_reporting.U6y4tz4UTGSn/mvce.rs:5:10
|
5 | pub fn g(n: &u8) {
| ^ help: if this is intentional, prefix it with an underscore: `_n`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
warning: unused variable: `xs`
--> /tmp/icemaker_global_tempdir.55XT4UoLqfnF/rustc_testrunner_tmpdir_reporting.U6y4tz4UTGSn/mvce.rs:6:9
|
6 | let mut xs = MaybeUninit::<[u8; N]>::uninit();
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_xs`
thread 'rustc' (703895) panicked at /rustc-dev/b1b08cdef5ed3bca71c0d6638fccadc90d2e0ea3/compiler/rustc_middle/src/mir/interpret/allocation.rs:483:13:
interpreter ran out of memory: cannot create allocation of 140668768878592 bytes
stack backtrace:
0: 0x7f69f18675c3 - <<std[df3da94de9706bd0]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[47ec0729a1a37b7]::fmt::Display>::fmt
1: 0x7f69f1e11648 - core[47ec0729a1a37b7]::fmt::write
2: 0x7f69f187dde6 - <std[df3da94de9706bd0]::sys::stdio::unix::Stderr as std[df3da94de9706bd0]::io::Write>::write_fmt
3: 0x7f69f183dd48 - std[df3da94de9706bd0]::panicking::default_hook::{closure#0}
4: 0x7f69f185b493 - std[df3da94de9706bd0]::panicking::default_hook
5: 0x7f69f08c8277 - std[df3da94de9706bd0]::panicking::update_hook::<alloc[a01b2a37b5952840]::boxed::Box<rustc_driver_impl[3f11c8db0c776d51]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f69f185b772 - std[df3da94de9706bd0]::panicking::panic_with_hook
7: 0x7f69f183de08 - std[df3da94de9706bd0]::panicking::panic_handler::{closure#0}
8: 0x7f69f1834e39 - std[df3da94de9706bd0]::sys::backtrace::__rust_end_short_backtrace::<std[df3da94de9706bd0]::panicking::panic_handler::{closure#0}, !>
9: 0x7f69f183f9bd - __rustc[8c48a1f37a164a59]::rust_begin_unwind
10: 0x7f69eeae05fc - core[47ec0729a1a37b7]::panicking::panic_fmt
11: 0x7f69f2b70b2c - <rustc_const_eval[d355dbbcb39bab7e]::interpret::eval_context::InterpCx<rustc_const_eval[d355dbbcb39bab7e]::const_eval::dummy_machine::DummyMachine>>::allocate
12: 0x7f69f2ae4ed7 - <rustc_mir_transform[a557afe3a9c10d78]::gvn::VnState as rustc_middle[ce3e2e9bc33d0b6b]::mir::visit::MutVisitor>::visit_assign
13: 0x7f69f2adc770 - <rustc_mir_transform[a557afe3a9c10d78]::gvn::GVN as rustc_mir_transform[a557afe3a9c10d78]::pass_manager::MirPass>::run_pass
14: 0x7f69f1e073ba - rustc_mir_transform[a557afe3a9c10d78]::run_optimization_passes
15: 0x7f69f2b18d01 - rustc_mir_transform[a557afe3a9c10d78]::optimized_mir
16: 0x7f69f2b1891d - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>
17: 0x7f69f1e1a346 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::DefIdCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
18: 0x7f69f1e1991b - rustc_query_impl[aa45c6b6de51583c]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
19: 0x7f69ef028acc - rustc_mir_transform[a557afe3a9c10d78]::cross_crate_inline::cross_crate_inlinable
20: 0x7f69f239b525 - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::cross_crate_inlinable::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 1usize]>>
21: 0x7f69f239c226 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::DefIdCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
22: 0x7f69f239bea4 - rustc_query_impl[aa45c6b6de51583c]::query_impl::cross_crate_inlinable::get_query_non_incr::__rust_end_short_backtrace
23: 0x7f69f2856083 - rustc_mir_transform[a557afe3a9c10d78]::inline::process_blocks::<rustc_mir_transform[a557afe3a9c10d78]::inline::NormalInliner>
24: 0x7f69f2c689f4 - <rustc_mir_transform[a557afe3a9c10d78]::inline::Inline as rustc_mir_transform[a557afe3a9c10d78]::pass_manager::MirPass>::run_pass
25: 0x7f69f1e073ba - rustc_mir_transform[a557afe3a9c10d78]::run_optimization_passes
26: 0x7f69f2b18d01 - rustc_mir_transform[a557afe3a9c10d78]::optimized_mir
27: 0x7f69f2b1891d - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>
28: 0x7f69f1e1a346 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::DefIdCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
29: 0x7f69f1e1991b - rustc_query_impl[aa45c6b6de51583c]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
30: 0x7f69ef028acc - rustc_mir_transform[a557afe3a9c10d78]::cross_crate_inline::cross_crate_inlinable
31: 0x7f69f239b525 - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::cross_crate_inlinable::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 1usize]>>
32: 0x7f69f239c226 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::DefIdCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
33: 0x7f69f239bea4 - rustc_query_impl[aa45c6b6de51583c]::query_impl::cross_crate_inlinable::get_query_non_incr::__rust_end_short_backtrace
34: 0x7f69f24353b1 - rustc_passes[23d5f182b7bd7d4e]::reachable::recursively_reachable
35: 0x7f69f24321a2 - rustc_passes[23d5f182b7bd7d4e]::reachable::reachable_set
36: 0x7f69f2f91aa8 - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::reachable_set::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>
37: 0x7f69f2f910d9 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::SingleCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
38: 0x7f69f2f918de - rustc_query_impl[aa45c6b6de51583c]::query_impl::reachable_set::get_query_non_incr::__rust_end_short_backtrace
39: 0x7f69f23788ee - rustc_codegen_ssa[ceea3e5e62e2720c]::back::symbol_export::reachable_non_generics_provider
40: 0x7f69f2ebd081 - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::reachable_non_generics::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>>
41: 0x7f69f1fa7678 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_data_structures[380a07e47053320]::vec_cache::VecCache<rustc_span[9014bc08a1a93b2a]::def_id::CrateNum, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[9d2c403936bd30b5]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
42: 0x7f69f23a0527 - rustc_query_impl[aa45c6b6de51583c]::query_impl::reachable_non_generics::get_query_non_incr::__rust_end_short_backtrace
43: 0x7f69f356415a - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::is_reachable_non_generic::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 1usize]>>.warm
44: 0x7f69f239c226 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::DefIdCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
45: 0x7f69f239bc24 - rustc_query_impl[aa45c6b6de51583c]::query_impl::is_reachable_non_generic::get_query_non_incr::__rust_end_short_backtrace
46: 0x7f69f23a351d - <rustc_monomorphize[affe3e76e9a9a314]::collector::RootCollector>::push_if_root
47: 0x7f69f23a4459 - rustc_monomorphize[affe3e76e9a9a314]::collector::collect_roots
48: 0x7f69f281b784 - rustc_monomorphize[affe3e76e9a9a314]::partitioning::collect_and_partition_mono_items
49: 0x7f69f3250556 - rustc_query_impl[aa45c6b6de51583c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[aa45c6b6de51583c]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 24usize]>>
50: 0x7f69f325051b - <rustc_query_impl[aa45c6b6de51583c]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[47ec0729a1a37b7]::ops::function::FnOnce<(rustc_middle[ce3e2e9bc33d0b6b]::ty::context::TyCtxt, ())>>::call_once
51: 0x7f69f3250076 - rustc_query_system[9d2c403936bd30b5]::query::plumbing::try_execute_query::<rustc_query_impl[aa45c6b6de51583c]::DynamicConfig<rustc_query_system[9d2c403936bd30b5]::query::caches::SingleCache<rustc_middle[ce3e2e9bc33d0b6b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[aa45c6b6de51583c]::plumbing::QueryCtxt, false>
52: 0x7f69f324fe1b - rustc_query_impl[aa45c6b6de51583c]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
53: 0x7f69f3184bec - rustc_codegen_ssa[ceea3e5e62e2720c]::base::codegen_crate::<rustc_codegen_llvm[8580819ac05d37d1]::LlvmCodegenBackend>
54: 0x7f69f31826b3 - <rustc_codegen_llvm[8580819ac05d37d1]::LlvmCodegenBackend as rustc_codegen_ssa[ceea3e5e62e2720c]::traits::backend::CodegenBackend>::codegen_crate
55: 0x7f69f3160b8c - <rustc_interface[e68c907aa599281b]::queries::Linker>::codegen_and_build_linker
56: 0x7f69f315d958 - <rustc_interface[e68c907aa599281b]::passes::create_and_enter_global_ctxt<core[47ec0729a1a37b7]::option::Option<rustc_interface[e68c907aa599281b]::queries::Linker>, rustc_driver_impl[3f11c8db0c776d51]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[47ec0729a1a37b7]::ops::function::FnOnce<(&rustc_session[628a9b3e6733b5c6]::session::Session, rustc_middle[ce3e2e9bc33d0b6b]::ty::context::CurrentGcx, alloc[a01b2a37b5952840]::sync::Arc<rustc_data_structures[380a07e47053320]::jobserver::Proxy>, &std[df3da94de9706bd0]::sync::once_lock::OnceLock<rustc_middle[ce3e2e9bc33d0b6b]::ty::context::GlobalCtxt>, &rustc_data_structures[380a07e47053320]::sync::worker_local::WorkerLocal<rustc_middle[ce3e2e9bc33d0b6b]::arena::Arena>, &rustc_data_structures[380a07e47053320]::sync::worker_local::WorkerLocal<rustc_hir[9a2ba165fdea807f]::Arena>, rustc_driver_impl[3f11c8db0c776d51]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
57: 0x7f69f2fbb545 - rustc_interface[e68c907aa599281b]::interface::run_compiler::<(), rustc_driver_impl[3f11c8db0c776d51]::run_compiler::{closure#0}>::{closure#1}
58: 0x7f69f2f1f4ca - std[df3da94de9706bd0]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e68c907aa599281b]::util::run_in_thread_with_globals<rustc_interface[e68c907aa599281b]::util::run_in_thread_pool_with_globals<rustc_interface[e68c907aa599281b]::interface::run_compiler<(), rustc_driver_impl[3f11c8db0c776d51]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
59: 0x7f69f2f1f29d - <std[df3da94de9706bd0]::thread::lifecycle::spawn_unchecked<rustc_interface[e68c907aa599281b]::util::run_in_thread_with_globals<rustc_interface[e68c907aa599281b]::util::run_in_thread_pool_with_globals<rustc_interface[e68c907aa599281b]::interface::run_compiler<(), rustc_driver_impl[3f11c8db0c776d51]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[47ec0729a1a37b7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
60: 0x7f69f2f1d678 - <std[df3da94de9706bd0]::sys::thread::unix::Thread>::new::thread_start
61: 0x7f69eca969cb - <unknown>
62: 0x7f69ecb1aa0c - <unknown>
63: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: rustc 1.93.0-nightly (b1b08cdef 2025-12-04) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z mir-opt-level=5 -Z dump-mir-dir=dir
query stack during panic:
#0 [optimized_mir] optimizing MIR for `g`
#1 [cross_crate_inlinable] whether the item should be made inlinable across crates
#2 [optimized_mir] optimizing MIR for `main`
#3 [cross_crate_inlinable] whether the item should be made inlinable across crates
#4 [reachable_set] reachability
#5 [reachable_non_generics] looking up the exported symbols of a crate
#6 [is_reachable_non_generic] checking whether `g` is an exported symbol
#7 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
warning: 3 warnings emitted
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)Area: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.