Skip to content

ICE: invalid immediate for given destination place: value ScalarPair .. does not match ABI #131507

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
matthiaskrgr opened this issue Oct 10, 2024 · 3 comments
Assignees
Labels
A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![feature(non_lifetime_binders)]
fn Brick()
where
    for<T> T: Copy,
{
    let mut foo: Option<Box<_>> = Some(Box::new(8));
    let f = move || {
        println!("'{}'", foo.unwrap());
    };
    f();
}

original:

#![feature(attr_literals)]

fn Brick() where for<T> T: Copy {
    let mut foo: Option<Box<_>> = Some(Box::new(8));
    let f = move|| {
        match foo {
            None => {},
            Some(x) => {
                foo = Some(x);
            }
        }
        println!("'{}'", foo.unwrap());
    };
    f();
}

fn main() {
    foo();
}

Version information

rustc 1.83.0-nightly (8d94e06ec 2024-10-10)
binary: rustc
commit-hash: 8d94e06ec9758b5c03ea77bb5dab22a1a76bc261
commit-date: 2024-10-10
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir -Zcrate-attr=feature(non_lifetime_binders)

Program output

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(non_lifetime_binders)
  |         ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.UkDLZIiGWuhn/rustc_testrunner_tmpdir_reporting.sOtl1K9lpDK5/mvce.rs:10:2
   |
10 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.UkDLZIiGWuhn/rustc_testrunner_tmpdir_reporting.sOtl1K9lpDK5/mvce.rs`

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.UkDLZIiGWuhn/rustc_testrunner_tmpdir_reporting.sOtl1K9lpDK5/mvce.rs:5:9
  |
5 |     let mut foo: Option<Box<_>> = Some(Box::new(8));
  |         ----^^^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

error: internal compiler error: compiler/rustc_const_eval/src/interpret/operand.rs:157:17: invalid immediate for given destination place: value ScalarPair(alloc5<imm>, 0x0000000000000001) does not match ABI Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }))

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operand.rs:157:17:
Box<dyn Any>
stack backtrace:
   0:     0x71a61e1d6a5a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha20e66cea8d40da6
   1:     0x71a61ea034a6 - core::fmt::write::hf2daaa73a1dc1c93
   2:     0x71a61fc02e51 - std::io::Write::write_fmt::h378271f9be5fe2f8
   3:     0x71a61e1d68b2 - std::sys::backtrace::BacktraceLock::print::hc64e8d2bde51fd49
   4:     0x71a61e1d8d86 - std::panicking::default_hook::{{closure}}::h0d83bed2db8cab1c
   5:     0x71a61e1d8bd0 - std::panicking::default_hook::h128ef1b79513126f
   6:     0x71a61d22df6f - std[a9199b77cdff7b9b]::panicking::update_hook::<alloc[226919ebccef61a6]::boxed::Box<rustc_driver_impl[92ba7bf89b2038aa]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x71a61e1d9498 - std::panicking::rust_panic_with_hook::h5cd591a4b9cf7e7b
   8:     0x71a61d267a51 - std[a9199b77cdff7b9b]::panicking::begin_panic::<rustc_errors[62337987763b3873]::ExplicitBug>::{closure#0}
   9:     0x71a61d25aaf6 - std[a9199b77cdff7b9b]::sys::backtrace::__rust_end_short_backtrace::<std[a9199b77cdff7b9b]::panicking::begin_panic<rustc_errors[62337987763b3873]::ExplicitBug>::{closure#0}, !>
  10:     0x71a61d25aab3 - std[a9199b77cdff7b9b]::panicking::begin_panic::<rustc_errors[62337987763b3873]::ExplicitBug>
  11:     0x71a61d2712e1 - <rustc_errors[62337987763b3873]::diagnostic::BugAbort as rustc_errors[62337987763b3873]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x71a61d8ca144 - rustc_middle[d89ba7dfe97f8d9e]::util::bug::opt_span_bug_fmt::<rustc_span[80b8a8e8ce77617b]::span_encoding::Span>::{closure#0}
  13:     0x71a61d8affca - rustc_middle[d89ba7dfe97f8d9e]::ty::context::tls::with_opt::<rustc_middle[d89ba7dfe97f8d9e]::util::bug::opt_span_bug_fmt<rustc_span[80b8a8e8ce77617b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x71a61d8afe5b - rustc_middle[d89ba7dfe97f8d9e]::ty::context::tls::with_context_opt::<rustc_middle[d89ba7dfe97f8d9e]::ty::context::tls::with_opt<rustc_middle[d89ba7dfe97f8d9e]::util::bug::opt_span_bug_fmt<rustc_span[80b8a8e8ce77617b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x71a61adf99a0 - rustc_middle[d89ba7dfe97f8d9e]::util::bug::bug_fmt
  16:     0x71a61c1dbf23 - <rustc_const_eval[71c2be5c4d1e6846]::interpret::eval_context::InterpCx<rustc_const_eval[71c2be5c4d1e6846]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  17:     0x71a61c173403 - rustc_const_eval[71c2be5c4d1e6846]::const_eval::eval_queries::eval_to_allocation_raw_provider
  18:     0x71a61f11f2f6 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>
  19:     0x71a61f11eb1a - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::DefaultCache<rustc_middle[d89ba7dfe97f8d9e]::ty::ParamEnvAnd<rustc_middle[d89ba7dfe97f8d9e]::mir::interpret::GlobalId>, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  20:     0x71a61f11e6ef - rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  21:     0x71a61f12055f - rustc_const_eval[71c2be5c4d1e6846]::const_eval::eval_queries::eval_to_const_value_raw_provider
  22:     0x71a61f120376 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>
  23:     0x71a61f11eadd - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::DefaultCache<rustc_middle[d89ba7dfe97f8d9e]::ty::ParamEnvAnd<rustc_middle[d89ba7dfe97f8d9e]::mir::interpret::GlobalId>, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  24:     0x71a61f11e5f3 - rustc_query_impl[121dfa8c420f6771]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  25:     0x71a61b620a96 - <rustc_middle[d89ba7dfe97f8d9e]::ty::context::TyCtxt>::const_eval_resolve
  26:     0x71a61f4d7074 - <rustc_mir_transform[494498406daaddfd]::gvn::VnState>::insert
  27:     0x71a61f4d2d4d - <rustc_mir_transform[494498406daaddfd]::gvn::VnState>::simplify_operand
  28:     0x71a61be885f4 - <rustc_mir_transform[494498406daaddfd]::gvn::GVN as rustc_mir_transform[494498406daaddfd]::pass_manager::MirPass>::run_pass
  29:     0x71a61ea0b70d - rustc_mir_transform[494498406daaddfd]::pass_manager::run_passes_inner
  30:     0x71a61ed082e2 - rustc_mir_transform[494498406daaddfd]::optimized_mir
  31:     0x71a61ed06ba1 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 8usize]>>
  32:     0x71a61ed58778 - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::DefIdCache<rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  33:     0x71a61ed57d33 - rustc_query_impl[121dfa8c420f6771]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  34:     0x71a61bcd0cc4 - <rustc_middle[d89ba7dfe97f8d9e]::ty::context::TyCtxt>::instance_mir
  35:     0x71a61ee7b30a - rustc_interface[70865a4857b6d971]::passes::run_required_analyses
  36:     0x71a61f75c35e - rustc_interface[70865a4857b6d971]::passes::analysis
  37:     0x71a61f75c331 - rustc_query_impl[121dfa8c420f6771]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[121dfa8c420f6771]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 1usize]>>
  38:     0x71a61f8fc62e - rustc_query_system[f00ba4d010ca6a7e]::query::plumbing::try_execute_query::<rustc_query_impl[121dfa8c420f6771]::DynamicConfig<rustc_query_system[f00ba4d010ca6a7e]::query::caches::SingleCache<rustc_middle[d89ba7dfe97f8d9e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[121dfa8c420f6771]::plumbing::QueryCtxt, false>
  39:     0x71a61f8fc30f - rustc_query_impl[121dfa8c420f6771]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x71a61f753b5e - rustc_interface[70865a4857b6d971]::interface::run_compiler::<core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>, rustc_driver_impl[92ba7bf89b2038aa]::run_compiler::{closure#0}>::{closure#1}
  41:     0x71a61f7d9450 - std[a9199b77cdff7b9b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[70865a4857b6d971]::util::run_in_thread_with_globals<rustc_interface[70865a4857b6d971]::util::run_in_thread_pool_with_globals<rustc_interface[70865a4857b6d971]::interface::run_compiler<core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>, rustc_driver_impl[92ba7bf89b2038aa]::run_compiler::{closure#0}>::{closure#1}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>
  42:     0x71a61f7d9b17 - <<std[a9199b77cdff7b9b]::thread::Builder>::spawn_unchecked_<rustc_interface[70865a4857b6d971]::util::run_in_thread_with_globals<rustc_interface[70865a4857b6d971]::util::run_in_thread_pool_with_globals<rustc_interface[70865a4857b6d971]::interface::run_compiler<core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>, rustc_driver_impl[92ba7bf89b2038aa]::run_compiler::{closure#0}>::{closure#1}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a4436d16a4783843]::result::Result<(), rustc_span[80b8a8e8ce77617b]::ErrorGuaranteed>>::{closure#1} as core[a4436d16a4783843]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x71a61f7daa01 - std::sys::pal::unix::thread::Thread::new::thread_start::h1576647e75736287
  44:     0x71a620e6139d - <unknown>
  45:     0x71a620ee649c - <unknown>
  46:                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 (8d94e06ec 2024-10-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z crate-attr=feature(non_lifetime_binders) -Z dump-mir-dir=dir

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `Brick::{closure#0}::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `Brick::{closure#0}::promoted[0]`
end of query stack
error: aborting due to 2 previous errors; 2 warnings emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-non_lifetime_binders

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 10, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` labels Oct 10, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Oct 10, 2024

Reduced:

#![feature(non_lifetime_binders)]

fn brick()
where
    for<T> T: Copy,
{
    || format_args!("");
}

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 11, 2024
@compiler-errors compiler-errors self-assigned this Oct 11, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Oct 20, 2024
@matthiaskrgr
Copy link
Member Author

reproducible with -Zmir-enable-passes=+GVN -Zmir-enable-passes=+Inline -Zvalidate-mir

@matthiaskrgr matthiaskrgr added A-mir-opt-inlining Area: MIR inlining A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) labels Dec 19, 2024
@m-ou-se
Copy link
Member

m-ou-se commented Feb 19, 2025

This can be reproduced without format_args!():

#![feature(non_lifetime_binders)]

fn brick()
where
    for<T> T: Copy,
{
    || Some::<&[()]>(&[]);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants