Skip to content

[ICE]: OOM: failed to allocate for uninit check -Zstrict-init-check #160769

Description

@matthiaskrgr

snippet:

//@compile-flags: -Zalways-encode-mir -Zstrict-init-checks=yes
fn overflow() -> [[[bool; 9999999]; 777777777]; 239] {
    unsafe { core::mem::zeroed() }
}

fn main() {
    let _ = overflow();
}

Version information

rustc 1.99.0-nightly (49c80b5a0 2026-08-08)
binary: rustc
commit-hash: 49c80b5a0db8abd63315c04ff34f58629e388281
commit-date: 2026-08-08
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

Possibly related line of code:

let machine = CompileTimeMachine::new(CanAccessMutGlobal::No, CheckAlignment::Error);
let mut cx = InterpCx::new(cx.tcx(), DUMMY_SP, cx.typing_env, machine);
// It doesn't really matter which `MemoryKind` we use here, `Stack` is the least wrong.
let allocated =
cx.allocate(ty, MemoryKind::Stack).expect("OOM: failed to allocate for uninit check");
if kind == ValidityRequirement::Zero {
cx.write_bytes_ptr(
allocated.ptr(),
std::iter::repeat_n(0_u8, ty.layout.size().bytes_usize()),
)

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zalways-encode-mir -Zstrict-init-checks=yes

Program output


thread 'rustc' (1112573) panicked at /rustc-dev/49c80b5a0db8abd63315c04ff34f58629e388281/compiler/rustc_const_eval/src/util/check_validity_requirement.rs:58:44:
OOM: failed to allocate for uninit check: InterpErrorInfo(InterpErrorInfoInner { kind: ResourceExhaustion(MemoryExhausted), backtrace: InterpErrorBacktrace { backtrace: None } })
stack backtrace:
   0:     0x7fa132f06146 - <<std[999cce9698cb2e30]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[611a668b6db07504]::fmt::Display>::fmt
   1:     0x7fa13361190f - core[611a668b6db07504]::fmt::write
   2:     0x7fa132f1b06c - <std[999cce9698cb2e30]::sys::stdio::unix::Stderr as core[611a668b6db07504]::io::write::Write>::write_fmt
   3:     0x7fa132ed91ba - std[999cce9698cb2e30]::panicking::default_hook::{closure#0}
   4:     0x7fa132ef9ed3 - std[999cce9698cb2e30]::panicking::default_hook
   5:     0x7fa131e3feaa - std[999cce9698cb2e30]::panicking::update_hook::<alloc[9c4b63ad13971f33]::boxed::Box<rustc_driver_impl[1d9b9be3672627fe]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fa132efa372 - std[999cce9698cb2e30]::panicking::panic_with_hook
   7:     0x7fa132ed9272 - std[999cce9698cb2e30]::panicking::panic_handler::{closure#0}
   8:     0x7fa132ed1669 - std[999cce9698cb2e30]::sys::backtrace::__rust_end_short_backtrace::<std[999cce9698cb2e30]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fa132edac4d - __rustc[a528db767ab46065]::rust_begin_unwind
  10:     0x7fa12fbc926c - core[611a668b6db07504]::panicking::panic_fmt
  11:     0x7fa12f3410c2 - core[611a668b6db07504]::result::unwrap_failed
  12:     0x7fa1314281c9 - rustc_const_eval[94f721029e7812d6]::util::check_validity_requirement::check_validity_requirement
  13:     0x7fa134a162d8 - rustc_query_impl[e0a7c844c3569b46]::query_impl::check_validity_requirement::invoke_provider_fn::__rust_begin_short_backtrace
  14:     0x7fa134a159b0 - rustc_query_impl[e0a7c844c3569b46]::execution::try_execute_query::<rustc_middle[842db40099f2c7a0]::query::caches::DefaultCache<(rustc_middle[842db40099f2c7a0]::ty::layout::ValidityRequirement, rustc_middle[842db40099f2c7a0]::ty::PseudoCanonicalInput<rustc_middle[842db40099f2c7a0]::ty::Ty>), rustc_middle[842db40099f2c7a0]::query::erase::ErasedData<[u8; 16usize]>>, false>
  15:     0x7fa134a15653 - rustc_query_impl[e0a7c844c3569b46]::query_impl::check_validity_requirement::execute_query_non_incr::__rust_end_short_backtrace
  16:     0x7fa134a8a62f - rustc_codegen_ssa[9d2ef248dbc53dd3]::mir::codegen_mir::<rustc_codegen_llvm[37ce2c06ea606dca]::builder::GenericBuilder<rustc_codegen_llvm[37ce2c06ea606dca]::context::FullCx>>
  17:     0x7fa133a5188f - rustc_codegen_llvm[37ce2c06ea606dca]::base::compile_codegen_unit::module_codegen
  18:     0x7fa1346a05b6 - <rustc_codegen_llvm[37ce2c06ea606dca]::LlvmCodegenBackend as rustc_codegen_ssa[9d2ef248dbc53dd3]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  19:     0x7fa13469c39a - rustc_codegen_ssa[9d2ef248dbc53dd3]::base::codegen_crate::<rustc_codegen_llvm[37ce2c06ea606dca]::LlvmCodegenBackend, rustc_codegen_llvm[37ce2c06ea606dca]::ModuleLlvm>
  20:     0x7fa13469ad4c - <rustc_codegen_llvm[37ce2c06ea606dca]::LlvmCodegenBackend as rustc_codegen_ssa[9d2ef248dbc53dd3]::traits::backend::CodegenBackend>::codegen_crate
  21:     0x7fa134828aa5 - <rustc_interface[1a36412a1dda276]::queries::Linker>::codegen_and_build_linker
  22:     0x7fa134820495 - rustc_interface[1a36412a1dda276]::interface::run_compiler::<(), rustc_driver_impl[1d9b9be3672627fe]::run_compiler::{closure#0}>::{closure#2}
  23:     0x7fa134855ca4 - std[999cce9698cb2e30]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1a36412a1dda276]::util::run_in_thread_with_globals<rustc_interface[1a36412a1dda276]::util::run_in_thread_pool_with_globals<rustc_interface[1a36412a1dda276]::interface::run_compiler<(), rustc_driver_impl[1d9b9be3672627fe]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x7fa134855a6d - <std[999cce9698cb2e30]::thread::lifecycle::spawn_unchecked<rustc_interface[1a36412a1dda276]::util::run_in_thread_with_globals<rustc_interface[1a36412a1dda276]::util::run_in_thread_pool_with_globals<rustc_interface[1a36412a1dda276]::interface::run_compiler<(), rustc_driver_impl[1d9b9be3672627fe]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[611a668b6db07504]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7fa13485323a - <std[999cce9698cb2e30]::sys::thread::unix::Thread>::new::thread_start
  26:     0x7fa12dc97739 - <unknown>
  27:     0x7fa12dd1bedc - <unknown>
  28:                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.99.0-nightly (49c80b5a0 2026-08-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z always-encode-mir -Z strict-init-checks=yes -Z dump-mir-dir=dir

query stack during panic:
#0 [check_validity_requirement] checking validity requirement for `[[[bool; ValTree(Leaf(0x000000000098967f): usize)]; ValTree(Leaf(0x000000002e5bf271): usize)]; ValTree(Leaf(0x00000000000000ef): usize)]`: allows being left zeroed
end of query stack
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: exhausted memory during interpretation
  |
  = note: delayed at /rustc-dev/49c80b5a0db8abd63315c04ff34f58629e388281/compiler/rustc_middle/src/mir/interpret/allocation.rs:466:43
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<&str>
             4: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::allocate
             5: rustc_const_eval::util::check_validity_requirement::check_validity_requirement
             6: rustc_query_impl::query_impl::check_validity_requirement::invoke_provider_fn::__rust_begin_short_backtrace
             7: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<(rustc_middle::ty::layout::ValidityRequirement, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::Ty>), rustc_middle::query::erase::ErasedData<[u8; 16]>>, false>
             8: rustc_query_impl::query_impl::check_validity_requirement::execute_query_non_incr::__rust_end_short_backtrace
             9: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::GenericBuilder<rustc_codegen_llvm::context::FullCx>>
            10: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
            11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::compile_codegen_unit
            12: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend, rustc_codegen_llvm::ModuleLlvm>
            13: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
            14: <rustc_interface::queries::Linker>::codegen_and_build_linker
            15: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}
            16: std::sys::backtrace::__rust_begin_short_backtrace::<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#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            17: <std::thread::lifecycle::spawn_unchecked<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#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            18: <std::sys::thread::unix::Thread>::new::thread_start
            19: <unknown>
            20: <unknown>
          

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.99.0-nightly (49c80b5a0 2026-08-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z always-encode-mir -Z strict-init-checks=yes -Z dump-mir-dir=dir

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions