Skip to content

ICE: is not a body node: #124319

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

Closed
matthiaskrgr opened this issue Apr 24, 2024 · 3 comments
Closed

ICE: is not a body node: #124319

matthiaskrgr opened this issue Apr 24, 2024 · 3 comments
Labels
-Zpolymorphize Unstable option: Polymorphization. A-cranelift Things relevant to the [future] cranelift backend 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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 24, 2024

Code

static mut FOO: Foo = Foo {
    field: &mut [42] as *mut [i32] as *mut i32,
};

struct Foo {
    field: *mut i32,
}

unsafe impl Sync for Foo {}

fn main() {
    assert_eq!(unsafe { *FOO.field = 69; *FOO.field }, 69);
}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (40dcd796d 2024-04-23)
binary: rustc
commit-hash: 40dcd796d094b911b8b7b55a0519fb8e3d21680f
commit-date: 2024-04-23
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4

Error output

`rustc -Zcodegen-backend=cranelift -Zpolymorphize=on file.rs

<output>
Backtrace

error: internal compiler error: /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/compiler/rustc_middle/src/hir/map/mod.rs:294:19: DefId(0:8 ~ static_raw_pointer_interning2_b279bb2261a8e9dcc54e36f9dd1cbb13405743be[669d]::FOO::{constant#0}) is not a body node: Static { mutability: Mut, nested: true }

thread 'rustc' panicked at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/compiler/rustc_middle/src/hir/map/mod.rs:294:19:
Box<dyn Any>
stack backtrace:
   0:     0x7e3f08ecb935 - std::backtrace_rs::backtrace::libunwind::trace::h37b813bf04fe68da
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7e3f08ecb935 - std::backtrace_rs::backtrace::trace_unsynchronized::hab24bc6e401550c9
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7e3f08ecb935 - std::sys_common::backtrace::_print_fmt::h0ed8afb1f8b1b186
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7e3f08ecb935 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hfa93c2668fd48884
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7e3f08f1aa6b - core::fmt::rt::Argument::fmt::h8f2440e6cfd8c172
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/fmt/rt.rs:165:63
   5:     0x7e3f08f1aa6b - core::fmt::write::h519cf493456154e9
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/fmt/mod.rs:1157:21
   6:     0x7e3f08ec053f - std::io::Write::write_fmt::hdcb94510ddf24313
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/io/mod.rs:1832:15
   7:     0x7e3f08ecb70e - std::sys_common::backtrace::_print::h3db464b21f5c5cd6
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7e3f08ecb70e - std::sys_common::backtrace::print::h4f94a0796297aaac
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7e3f08ece079 - std::panicking::default_hook::{{closure}}::h73742c7c49d6bdc6
  10:     0x7e3f08ecddbd - std::panicking::default_hook::h03259a6dd63e0537
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/panicking.rs:298:9
  11:     0x7e3f0583caab - std[716fbccb88eab441]::panicking::update_hook::<alloc[6593a39c2066849c]::boxed::Box<rustc_driver_impl[2cb9e512ff9c01af]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7e3f08ece776 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h47f10f0c9cee1061
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/alloc/src/boxed.rs:2036:9
  13:     0x7e3f08ece776 - std::panicking::rust_panic_with_hook::hdef93bb45d728673
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/panicking.rs:799:13
  14:     0x7e3f0586cd84 - std[716fbccb88eab441]::panicking::begin_panic::<rustc_errors[457f7d3a29db740c]::ExplicitBug>::{closure#0}
  15:     0x7e3f05869736 - std[716fbccb88eab441]::sys_common::backtrace::__rust_end_short_backtrace::<std[716fbccb88eab441]::panicking::begin_panic<rustc_errors[457f7d3a29db740c]::ExplicitBug>::{closure#0}, !>
  16:     0x7e3f05864d36 - std[716fbccb88eab441]::panicking::begin_panic::<rustc_errors[457f7d3a29db740c]::ExplicitBug>
  17:     0x7e3f05876001 - <rustc_errors[457f7d3a29db740c]::diagnostic::BugAbort as rustc_errors[457f7d3a29db740c]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7e3f05d1cf4c - rustc_middle[98123958515d0133]::util::bug::opt_span_bug_fmt::<rustc_span[a5597b78f846b7ef]::span_encoding::Span>::{closure#0}
  19:     0x7e3f05d0478a - rustc_middle[98123958515d0133]::ty::context::tls::with_opt::<rustc_middle[98123958515d0133]::util::bug::opt_span_bug_fmt<rustc_span[a5597b78f846b7ef]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7e3f05d0460b - rustc_middle[98123958515d0133]::ty::context::tls::with_context_opt::<rustc_middle[98123958515d0133]::ty::context::tls::with_opt<rustc_middle[98123958515d0133]::util::bug::opt_span_bug_fmt<rustc_span[a5597b78f846b7ef]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7e3f03fe54e0 - rustc_middle[98123958515d0133]::util::bug::bug_fmt
  22:     0x7e3f05ec7989 - <rustc_middle[98123958515d0133]::hir::map::Map>::body_const_context::<rustc_span[a5597b78f846b7ef]::def_id::LocalDefId>
  23:     0x7e3f07403490 - rustc_query_impl[dc957dd79d9c76d8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[dc957dd79d9c76d8]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[98123958515d0133]::query::erase::Erased<[u8; 4usize]>>
  24:     0x7e3f07402d19 - rustc_query_system[dc3c1c377815842a]::query::plumbing::try_execute_query::<rustc_query_impl[dc957dd79d9c76d8]::DynamicConfig<rustc_query_system[dc3c1c377815842a]::query::caches::DefaultCache<rustc_middle[98123958515d0133]::ty::instance::InstanceDef, rustc_middle[98123958515d0133]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[dc957dd79d9c76d8]::plumbing::QueryCtxt, false>
  25:     0x7e3f07402a28 - rustc_query_impl[dc957dd79d9c76d8]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7e3f05d0ff64 - rustc_middle[98123958515d0133]::ty::instance::polymorphize
  27:     0x7e3f05d0fd3b - <rustc_middle[98123958515d0133]::ty::instance::Instance>::polymorphize
  28:     0x7e3ef881f264 - rustc_codegen_cranelift[d6f88c39893ffeba]::constant::data_id_for_static
  29:     0x7e3ef881d1ba - <rustc_codegen_cranelift[d6f88c39893ffeba]::constant::ConstantCx>::finalize
  30:     0x7e3ef8828256 - rustc_codegen_cranelift[d6f88c39893ffeba]::driver::aot::module_codegen::{closure#0}
  31:     0x7e3ef8826487 - rustc_codegen_cranelift[d6f88c39893ffeba]::driver::aot::module_codegen
  32:     0x7e3ef8833789 - rustc_codegen_cranelift[d6f88c39893ffeba]::driver::aot::run_aot
  33:     0x7e3ef8860f31 - <rustc_codegen_cranelift[d6f88c39893ffeba]::CraneliftCodegenBackend as rustc_codegen_ssa[3dfd2cd8284d5f95]::traits::backend::CodegenBackend>::codegen_crate
  34:     0x7e3f07aa629d - rustc_interface[9c928a10bc10dd72]::passes::start_codegen
  35:     0x7e3f07aa5918 - <rustc_interface[9c928a10bc10dd72]::queries::Queries>::codegen_and_build_linker
  36:     0x7e3f077f3236 - rustc_interface[9c928a10bc10dd72]::interface::run_compiler::<core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>, rustc_driver_impl[2cb9e512ff9c01af]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7e3f077dcd49 - std[716fbccb88eab441]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9c928a10bc10dd72]::util::run_in_thread_with_globals<rustc_interface[9c928a10bc10dd72]::util::run_in_thread_pool_with_globals<rustc_interface[9c928a10bc10dd72]::interface::run_compiler<core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>, rustc_driver_impl[2cb9e512ff9c01af]::run_compiler::{closure#0}>::{closure#1}, core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>>::{closure#0}, core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>>
  38:     0x7e3f077dcafa - <<std[716fbccb88eab441]::thread::Builder>::spawn_unchecked_<rustc_interface[9c928a10bc10dd72]::util::run_in_thread_with_globals<rustc_interface[9c928a10bc10dd72]::util::run_in_thread_pool_with_globals<rustc_interface[9c928a10bc10dd72]::interface::run_compiler<core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>, rustc_driver_impl[2cb9e512ff9c01af]::run_compiler::{closure#0}>::{closure#1}, core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>>::{closure#0}, core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6d1459b4b1018518]::result::Result<(), rustc_span[a5597b78f846b7ef]::ErrorGuaranteed>>::{closure#2} as core[6d1459b4b1018518]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7e3f08ed860b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2aa7472c794092b9
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/alloc/src/boxed.rs:2022:9
  40:     0x7e3f08ed860b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha0ae72bf75088542
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/alloc/src/boxed.rs:2022:9
  41:     0x7e3f08ed860b - std::sys::pal::unix::thread::Thread::new::thread_start::ha07f7010bd7bf45c
                               at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7e3f026a955a - <unknown>
  43:     0x7e3f02726a3c - <unknown>
  44:                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: please attach the file at `/tmp/im/rustc-ice-2024-04-24T04_15_14-3181386.txt` to your bug report

note: compiler flags: -Z codegen-backend=cranelift -Z polymorphize=on

query stack during panic:
#0 [unused_generic_params] determining which generic parameters are unused by `FOO::{constant#0}`
end of query stack

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. A-cranelift Things relevant to the [future] cranelift backend D-crate-version-mismatch Diagnostics: Errors or lints caused be the use of two different crate versions. -Zpolymorphize Unstable option: Polymorphization. labels Apr 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 24, 2024
@matthiaskrgr
Copy link
Member Author

Not sure what cranelift does different, havn't been able to trigger the ICE with llvm so far.

@matthiaskrgr matthiaskrgr removed the D-crate-version-mismatch Diagnostics: Errors or lints caused be the use of two different crate versions. label Apr 24, 2024
@bjorn3
Copy link
Member

bjorn3 commented Apr 24, 2024

Maybe I'm not supposed to call polymorphize on a static Instance?

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 24, 2024
@bjorn3
Copy link
Member

bjorn3 commented May 11, 2024

It was indeed the extra .polymorphize() call. cg_llvm doesn't have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zpolymorphize Unstable option: Polymorphization. A-cranelift Things relevant to the [future] cranelift backend 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.
Projects
None yet
Development

No branches or pull requests

4 participants