Skip to content

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

Closed

Description

@matthiaskrgr

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


Activity

  1. added
    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 Jul 17, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 17, 2024
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jul 17, 2024
  4. added a commit that references this issue on Jul 29, 2024
    2e9d962
  5. added a commit that references this issue on Jul 29, 2024
    ba1aad4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions