Skip to content
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

ICE: typeid_for_instance: couldn't get fn_abi of instance #127881

Closed
matthiaskrgr opened this issue Jul 17, 2024 · 0 comments · Fixed by #127882
Closed

ICE: typeid_for_instance: couldn't get fn_abi of instance #127881

matthiaskrgr opened this issue Jul 17, 2024 · 0 comments · Fixed by #127882
Assignees
Labels
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

snippet:

trait Foo {
    type Bar<'a>
    where
        Self: Sized;

    fn test(&self);
}

impl Foo for () {
    type Bar<'a> = () where Self: Sized;

    fn test(&self) {}
}

fn test(x: &dyn Foo) {
    x.test();
}

fn main() {
    test(&());
}

Version information

rustc 1.81.0-nightly (fcc325f1b 2024-07-17)
binary: rustc
commit-hash: fcc325f1bc477975e2ce5ba534fe4c77ff8a8536
commit-date: 2024-07-17
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zsanitizer=cfi -Ccodegen-units=1 -Clto

Program output

error: internal compiler error: compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs:121:13: typeid_for_instance: couldn't get fn_abi of instance Instance { def: Virtual(DefId(0:6 ~ mvce[89c4]::Foo::test), 0), args: [dyn [Binder { value: Trait(Foo), bound_vars: [] }, Binder { value: Projection(Bar = {type error}), bound_vars: [] }] + '{erased}] }: Layout(ReferencesError(ErrorGuaranteed(())))

thread 'rustc' panicked at compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/mod.rs:121:13:
Box<dyn Any>
stack backtrace:
   0:     0x7b216d6183e5 - std::backtrace_rs::backtrace::libunwind::trace::h7d42dda8f80cfb99
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7b216d6183e5 - std::backtrace_rs::backtrace::trace_unsynchronized::hd585f8afb233c9ee
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7b216d6183e5 - std::sys::backtrace::_print_fmt::h224c15dbafc899ab
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/backtrace.rs:65:5
   3:     0x7b216d6183e5 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hca750ad87bb2f1d4
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/backtrace.rs:40:26
   4:     0x7b216d667e3b - core::fmt::rt::Argument::fmt::hf85ec79e8cf86c67
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/core/src/fmt/rt.rs:173:76
   5:     0x7b216d667e3b - core::fmt::write::h133a0eb20f0a6a5d
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/core/src/fmt/mod.rs:1182:21
   6:     0x7b216d60ce9f - std::io::Write::write_fmt::h0b1c7497ddea4e96
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/io/mod.rs:1827:15
   7:     0x7b216d61abd1 - std::sys::backtrace::BacktraceLock::print::h7ea149d21a641076
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/backtrace.rs:43:9
   8:     0x7b216d61abd1 - std::panicking::default_hook::{{closure}}::h7dd45b5804215332
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/panicking.rs:269:22
   9:     0x7b216d61a8ac - std::panicking::default_hook::haed8ee3169af9669
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/panicking.rs:296:9
  10:     0x7b21699f5aa9 - std[a568119b01f6acf9]::panicking::update_hook::<alloc[bb4b795e710d07dc]::boxed::Box<rustc_driver_impl[8e1afaf50ebeb9ae]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x7b216d61b59f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h28c95c685643affe
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/alloc/src/boxed.rs:2084:9
  12:     0x7b216d61b59f - std::panicking::rust_panic_with_hook::h4bf66cb658082ab2
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/panicking.rs:808:13
  13:     0x7b2169a30361 - std[a568119b01f6acf9]::panicking::begin_panic::<rustc_errors[3a77a9bae9c6f06]::ExplicitBug>::{closure#0}
  14:     0x7b2169a23166 - std[a568119b01f6acf9]::sys::backtrace::__rust_end_short_backtrace::<std[a568119b01f6acf9]::panicking::begin_panic<rustc_errors[3a77a9bae9c6f06]::ExplicitBug>::{closure#0}, !>
  15:     0x7b2169a23116 - std[a568119b01f6acf9]::panicking::begin_panic::<rustc_errors[3a77a9bae9c6f06]::ExplicitBug>
  16:     0x7b2169a397e1 - <rustc_errors[3a77a9bae9c6f06]::diagnostic::BugAbort as rustc_errors[3a77a9bae9c6f06]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7b216a0467a4 - rustc_middle[755ee31b8896a314]::util::bug::opt_span_bug_fmt::<rustc_span[38ccacee260ae995]::span_encoding::Span>::{closure#0}
  18:     0x7b216a02c99a - rustc_middle[755ee31b8896a314]::ty::context::tls::with_opt::<rustc_middle[755ee31b8896a314]::util::bug::opt_span_bug_fmt<rustc_span[38ccacee260ae995]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  19:     0x7b216a02c83b - rustc_middle[755ee31b8896a314]::ty::context::tls::with_context_opt::<rustc_middle[755ee31b8896a314]::ty::context::tls::with_opt<rustc_middle[755ee31b8896a314]::util::bug::opt_span_bug_fmt<rustc_span[38ccacee260ae995]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  20:     0x7b2167dc6e70 - rustc_middle[755ee31b8896a314]::util::bug::bug_fmt
  21:     0x7b216a50851e - rustc_sanitizers[1d6677b7696965d9]::cfi::typeid::itanium_cxx_abi::typeid_for_instance
  22:     0x7b2168235b48 - <rustc_codegen_llvm[87ee7f7790512990]::context::CodegenCx as rustc_codegen_ssa[a22e255770616fed]::traits::declare::PreDefineMethods>::predefine_fn
  23:     0x7b216bdea4dc - rustc_codegen_llvm[87ee7f7790512990]::base::compile_codegen_unit::module_codegen
  24:     0x7b216bde783c - <rustc_codegen_llvm[87ee7f7790512990]::LlvmCodegenBackend as rustc_codegen_ssa[a22e255770616fed]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  25:     0x7b216bfbaab1 - <rustc_codegen_llvm[87ee7f7790512990]::LlvmCodegenBackend as rustc_codegen_ssa[a22e255770616fed]::traits::backend::CodegenBackend>::codegen_crate
  26:     0x7b216bf63cb6 - <rustc_interface[a03dee3aea9b1fd5]::queries::Linker>::codegen_and_build_linker
  27:     0x7b216bdc13f6 - rustc_interface[a03dee3aea9b1fd5]::interface::run_compiler::<core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>, rustc_driver_impl[8e1afaf50ebeb9ae]::run_compiler::{closure#0}>::{closure#1}
  28:     0x7b216bd97b49 - std[a568119b01f6acf9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_with_globals<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_pool_with_globals<rustc_interface[a03dee3aea9b1fd5]::interface::run_compiler<core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>, rustc_driver_impl[8e1afaf50ebeb9ae]::run_compiler::{closure#0}>::{closure#1}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>
  29:     0x7b216bd978fa - <<std[a568119b01f6acf9]::thread::Builder>::spawn_unchecked_<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_with_globals<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_pool_with_globals<rustc_interface[a03dee3aea9b1fd5]::interface::run_compiler<core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>, rustc_driver_impl[8e1afaf50ebeb9ae]::run_compiler::{closure#0}>::{closure#1}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#2} as core[da8eb5c0cc453d3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7b216d6255fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcba9444f62f4d2cf
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/alloc/src/boxed.rs:2070:9
  31:     0x7b216d6255fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h370ba06625738899
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/alloc/src/boxed.rs:2070:9
  32:     0x7b216d6255fb - std::sys::pal::unix::thread::Thread::new::thread_start::he74bac229ff12ca4
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/pal/unix/thread.rs:108:17
  33:     0x7b216d3b9ded - <unknown>
  34:     0x7b216d43d0dc - <unknown>
  35:                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.81.0-nightly (fcc325f1b 2024-07-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z sanitizer=cfi -C codegen-units=1 -C lto -Z dump-mir-dir=dir

query stack during panic:
end of query stack
error: aborting due to 1 previous error


@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. labels Jul 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 17, 2024
@compiler-errors compiler-errors self-assigned this Jul 17, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 17, 2024
@bors bors closed this as completed in 2e9d962 Jul 29, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 29, 2024
Rollup merge of rust-lang#127882 - compiler-errors:cfi-sized-self-gat, r=oli-obk

Don't elaborate associated types with Sized bounds in `trait_object_ty` in cfi

The elaboration mechanism introduced in rust-lang#123005 didn't filter for associated types with `Self: Sized` bounds, which since rust-lang#112319 has excluded them from the object type.

Fixes rust-lang#127881
cc `@maurer` `@rcvalle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

4 participants