Skip to content

ICE: interpret const eval failure of Unevaluated(UnevaluatedConst #130687

Closed

Description

@matthiaskrgr

snippet:

pub struct Data([u8; usize::MAX >> 16]);
const _: &'static Data = &Data([0; usize::MAX >> 16]);

Version information

rustc 1.83.0-nightly (55043f067 2024-09-22)
binary: rustc
commit-hash: 55043f067dcf7067e7c6ebccf3639af94ff57bda
commit-date: 2024-09-22
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.uajd7BjF457F/rustc_testrunner_tmpdir_reporting.GJfRmJzXgPMl/mvce.rs:2:55
  |
2 | const _: &'static Data = &Data([0; usize::MAX >> 16]);
  |                                                       ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.uajd7BjF457F/rustc_testrunner_tmpdir_reporting.GJfRmJzXgPMl/mvce.rs`

error[E0080]: evaluation of constant value failed
 --> /tmp/icemaker_global_tempdir.uajd7BjF457F/rustc_testrunner_tmpdir_reporting.GJfRmJzXgPMl/mvce.rs:2:32
  |
2 | const _: &'static Data = &Data([0; usize::MAX >> 16]);
  |                                ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler

error: internal compiler error: compiler/rustc_const_eval/src/interpret/eval_context.rs:586:33: interpret const eval failure of Unevaluated(UnevaluatedConst { def: DefId(0:7 ~ mvce[dab4]::_), args: [], promoted: Some(promoted[0]) }, &'{erased} Data) which is not in required_consts
 --> /tmp/icemaker_global_tempdir.uajd7BjF457F/rustc_testrunner_tmpdir_reporting.GJfRmJzXgPMl/mvce.rs:2:26
  |
2 | const _: &'static Data = &Data([0; usize::MAX >> 16]);
  |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/eval_context.rs:586:33:
Box<dyn Any>
stack backtrace:
   0:     0x7c179568af1a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd890a259e842de86
   1:     0x7c1795e03666 - core::fmt::write::ha27dfc921a37964e
   2:     0x7c1796d02333 - std::io::Write::write_fmt::h70c8a0cc59cad0a8
   3:     0x7c179568ad72 - std::sys::backtrace::BacktraceLock::print::h3013cc5c3ae4074f
   4:     0x7c179568d4f1 - std::panicking::default_hook::{{closure}}::h9e5c041fcf401891
   5:     0x7c179568d324 - std::panicking::default_hook::h788b5d87547559ac
   6:     0x7c179478495f - std[232e32126cf29c33]::panicking::update_hook::<alloc[d4d13292f8c1d48d]::boxed::Box<rustc_driver_impl[b1c9e4000593b067]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7c179568dc08 - std::panicking::rust_panic_with_hook::hb1c7ebf17e599033
   8:     0x7c17947bf061 - std[232e32126cf29c33]::panicking::begin_panic::<rustc_errors[c0761d72276853f8]::ExplicitBug>::{closure#0}
   9:     0x7c17947b2106 - std[232e32126cf29c33]::sys::backtrace::__rust_end_short_backtrace::<std[232e32126cf29c33]::panicking::begin_panic<rustc_errors[c0761d72276853f8]::ExplicitBug>::{closure#0}, !>
  10:     0x7c17947ad5d9 - std[232e32126cf29c33]::panicking::begin_panic::<rustc_errors[c0761d72276853f8]::ExplicitBug>
  11:     0x7c17947c88b1 - <rustc_errors[c0761d72276853f8]::diagnostic::BugAbort as rustc_errors[c0761d72276853f8]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7c17946da6fd - <rustc_errors[c0761d72276853f8]::DiagCtxtHandle>::span_bug::<rustc_span[4e9173d9ab4d4daa]::span_encoding::Span, alloc[d4d13292f8c1d48d]::string::String>
  13:     0x7c17946f60d8 - rustc_middle[2422fc0a2a72bca0]::util::bug::opt_span_bug_fmt::<rustc_span[4e9173d9ab4d4daa]::span_encoding::Span>::{closure#0}
  14:     0x7c17946f638a - rustc_middle[2422fc0a2a72bca0]::ty::context::tls::with_opt::<rustc_middle[2422fc0a2a72bca0]::util::bug::opt_span_bug_fmt<rustc_span[4e9173d9ab4d4daa]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x7c17946ea51b - rustc_middle[2422fc0a2a72bca0]::ty::context::tls::with_context_opt::<rustc_middle[2422fc0a2a72bca0]::ty::context::tls::with_opt<rustc_middle[2422fc0a2a72bca0]::util::bug::opt_span_bug_fmt<rustc_span[4e9173d9ab4d4daa]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x7c179367c547 - rustc_middle[2422fc0a2a72bca0]::util::bug::span_bug_fmt::<rustc_span[4e9173d9ab4d4daa]::span_encoding::Span>
  17:     0x7c17968eb5b4 - <rustc_const_eval[52bfe85ce8cf4586]::interpret::eval_context::InterpCx<rustc_const_eval[52bfe85ce8cf4586]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  18:     0x7c17936fadd2 - rustc_const_eval[52bfe85ce8cf4586]::const_eval::eval_queries::eval_to_allocation_raw_provider
  19:     0x7c1796501bb6 - rustc_query_impl[68ff1bc69f23602]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[68ff1bc69f23602]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>
  20:     0x7c1796502bef - <rustc_query_impl[68ff1bc69f23602]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core[7ac7550d2f2632cb]::ops::function::FnOnce<(rustc_middle[2422fc0a2a72bca0]::ty::context::TyCtxt, rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>)>>::call_once
  21:     0x7c1796502b71 - <rustc_query_system[67db78f99bfebbdc]::query::plumbing::execute_job_incr<rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::DefaultCache<rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core[7ac7550d2f2632cb]::ops::function::FnOnce<((rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt, rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::DefaultCache<rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>), rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>)>>::call_once
  22:     0x7c17965181ae - rustc_query_system[67db78f99bfebbdc]::query::plumbing::try_execute_query::<rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::DefaultCache<rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt, true>
  23:     0x7c17965176b6 - rustc_query_impl[68ff1bc69f23602]::query_impl::eval_to_allocation_raw::get_query_incr::__rust_end_short_backtrace
  24:     0x7c1796502e2e - rustc_const_eval[52bfe85ce8cf4586]::const_eval::eval_queries::eval_to_const_value_raw_provider
  25:     0x7c1796502c36 - rustc_query_impl[68ff1bc69f23602]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[68ff1bc69f23602]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>
  26:     0x7c1796502baf - <rustc_query_impl[68ff1bc69f23602]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2} as core[7ac7550d2f2632cb]::ops::function::FnOnce<(rustc_middle[2422fc0a2a72bca0]::ty::context::TyCtxt, rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>)>>::call_once
  27:     0x7c1796502b71 - <rustc_query_system[67db78f99bfebbdc]::query::plumbing::execute_job_incr<rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::DefaultCache<rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt>::{closure#2}::{closure#2} as core[7ac7550d2f2632cb]::ops::function::FnOnce<((rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt, rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::DefaultCache<rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>), rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>)>>::call_once
  28:     0x7c17965181ae - rustc_query_system[67db78f99bfebbdc]::query::plumbing::try_execute_query::<rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::DefaultCache<rustc_middle[2422fc0a2a72bca0]::ty::ParamEnvAnd<rustc_middle[2422fc0a2a72bca0]::mir::interpret::GlobalId>, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt, true>
  29:     0x7c1796517a4c - rustc_query_impl[68ff1bc69f23602]::query_impl::eval_to_const_value_raw::get_query_incr::__rust_end_short_backtrace
  30:     0x7c1796197c3d - <rustc_middle[2422fc0a2a72bca0]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[2606297559afc5bb]::check_crate::{closure#3}>::{closure#0}
  31:     0x7c17961954d2 - rustc_hir_analysis[2606297559afc5bb]::check_crate
  32:     0x7c1796191e05 - rustc_interface[3feab42be5996c7]::passes::run_required_analyses
  33:     0x7c1796a2a29e - rustc_interface[3feab42be5996c7]::passes::analysis
  34:     0x7c1796a2a271 - rustc_query_impl[68ff1bc69f23602]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[68ff1bc69f23602]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7c1796f261c1 - rustc_query_system[67db78f99bfebbdc]::query::plumbing::try_execute_query::<rustc_query_impl[68ff1bc69f23602]::DynamicConfig<rustc_query_system[67db78f99bfebbdc]::query::caches::SingleCache<rustc_middle[2422fc0a2a72bca0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[68ff1bc69f23602]::plumbing::QueryCtxt, true>
  36:     0x7c1796f25e7a - rustc_query_impl[68ff1bc69f23602]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  37:     0x7c1796b399de - rustc_interface[3feab42be5996c7]::interface::run_compiler::<core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>, rustc_driver_impl[b1c9e4000593b067]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7c1796bc4990 - std[232e32126cf29c33]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3feab42be5996c7]::util::run_in_thread_with_globals<rustc_interface[3feab42be5996c7]::util::run_in_thread_pool_with_globals<rustc_interface[3feab42be5996c7]::interface::run_compiler<core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>, rustc_driver_impl[b1c9e4000593b067]::run_compiler::{closure#0}>::{closure#1}, core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>>::{closure#0}, core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>>
  39:     0x7c1796bc4ffa - <<std[232e32126cf29c33]::thread::Builder>::spawn_unchecked_<rustc_interface[3feab42be5996c7]::util::run_in_thread_with_globals<rustc_interface[3feab42be5996c7]::util::run_in_thread_pool_with_globals<rustc_interface[3feab42be5996c7]::interface::run_compiler<core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>, rustc_driver_impl[b1c9e4000593b067]::run_compiler::{closure#0}>::{closure#1}, core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>>::{closure#0}, core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7ac7550d2f2632cb]::result::Result<(), rustc_span[4e9173d9ab4d4daa]::ErrorGuaranteed>>::{closure#1} as core[7ac7550d2f2632cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7c1796bc53eb - std::sys::pal::unix::thread::Thread::new::thread_start::h6e4c0266f3b27cf2
  41:     0x7c179825939d - <unknown>
  42:     0x7c17982de49c - <unknown>
  43:                0x0 - <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.83.0-nightly (55043f067 2024-09-22) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `_`
#1 [eval_to_const_value_raw] simplifying constant for the type system `_`
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0080, E0601.
For more information about an error, try `rustc --explain E0080`.

Activity

  1. added
    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.
    on Sep 22, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 22, 2024
  3. matthiaskrgr commented on Sep 22, 2024

    @matthiaskrgr
    MemberAuthor

    Regression in #127546 cc @workingjubilee

  4. added
    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
    on Sep 22, 2024
  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 22, 2024
  6. saethlin commented on Sep 22, 2024

    @saethlin
    Member

    Nope. That PR just changed the size at which things become problematic, which should tell you that the bisection is wrong. If you tweak the constants just a little bit:

    pub struct Data([u8; usize::MAX >> 17]);
    const _: &'static Data = &Data([0; usize::MAX >> 17]);

    This bisects instead to #121557

  7. workingjubilee commented on Sep 22, 2024

    @workingjubilee
    Member

    is "the compiler OOMs when you try to make it OOM" really a "regression"?

  8. workingjubilee commented on Sep 22, 2024

    @workingjubilee
    Member

    answer after some discussion: possibly, if it was supposed to stop compilation when it detected it was going to OOM if it continued!

  9. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    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.
    C-bugCategory: This is a bug.
    and removed
    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.
    C-bugCategory: This is a bug.
    on Sep 29, 2024
  10. RalfJung commented on Nov 9, 2024

    @RalfJung
    Member

    Ah, exciting... there is indeed a way that all constants can fail to evaluate, even those that have been promoted because they seem "infallible".

  11. added 4 commits that reference this issue on Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions