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

rustc panic on invalid input (maybe due to name collision)? #119933

Closed
QuinnFreedman opened this issue Jan 13, 2024 · 1 comment
Closed

rustc panic on invalid input (maybe due to name collision)? #119933

QuinnFreedman opened this issue Jan 13, 2024 · 1 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.

Comments

@QuinnFreedman
Copy link

I made an error where I forgot to include the &self in this minimal trait example. Also, there were multiple trait methods with the same name. It seems like the combination of these things causes a rustc panic.

Code

trait Foo {
    fn f();
}

trait Bar {
    fn f();
}

struct Baz {}

impl Foo for Baz {
    fn f() {
        println!("F");
    }
}


fn main() {
    let b = Baz {};
    b.f();
    println!("Hello");
}

This is currently reproducible in this Rust Playground https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eb7703a056233d9756edffd5eadcd3e6

Meta

rustc --version --verbose:

rustc 1.75.0 (82e1608df 2023-12-21) running on x86_64-unknown-linux-gnu

Error output

   Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/method/suggest.rs:3299:28:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7fa49bc5262c - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fa49bc5262c - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa49bc5262c - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fa49bc5262c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fa49bca5630 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:     0x7fa49bca5630 - core::fmt::write::h3a39390d8560d9c9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fa49bc4654f - std::io::Write::write_fmt::h5fc9997dfe05f882
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:     0x7fa49bc52414 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fa49bc52414 - std::sys_common::backtrace::print::h23a2d212c6fff936
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fa49bc550a7 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
  10:     0x7fa49bc54e0f - std::panicking::default_hook::h6038f2eba384e475
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:     0x7fa49e7fe190 - std[409886f6357001f0]::panicking::update_hook::<alloc[c1b021ad36e35877]::boxed::Box<rustc_driver_impl[7d23c5715ff089db]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fa49bc557e8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1f8f335eaa9cfaee
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  13:     0x7fa49bc557e8 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
  14:     0x7fa49bc5553e - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  15:     0x7fa49bc52af6 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7fa49bc552a2 - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  17:     0x7fa49bca1d15 - core::panicking::panic_fmt::hbf0e066aabfa482c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  18:     0x7fa49bca1f32 - core::panicking::panic_bounds_check::h326a19b32dc06d6d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:190:5
  19:     0x7fa49ea093a4 - rustc_hir_typeck[2eba1876834da1d1]::method::suggest::print_disambiguation_help
  20:     0x7fa49e9fdaa1 - <rustc_hir_typeck[2eba1876834da1d1]::fn_ctxt::FnCtxt>::note_candidates_on_method_error
  21:     0x7fa49e9f43f0 - <rustc_hir_typeck[2eba1876834da1d1]::fn_ctxt::FnCtxt>::report_no_match_method_error
  22:     0x7fa49ea18135 - <rustc_hir_typeck[2eba1876834da1d1]::fn_ctxt::FnCtxt>::report_method_error
  23:     0x7fa4a0591026 - <rustc_hir_typeck[2eba1876834da1d1]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x7fa4a003f599 - <rustc_hir_typeck[2eba1876834da1d1]::fn_ctxt::FnCtxt>::check_block_with_expected
  25:     0x7fa4a05877a9 - <rustc_hir_typeck[2eba1876834da1d1]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x7fa4a02824fe - rustc_hir_typeck[2eba1876834da1d1]::check::check_fn
  27:     0x7fa49fe1c353 - rustc_hir_typeck[2eba1876834da1d1]::typeck
  28:     0x7fa49fe1b7c7 - rustc_query_impl[664ae873a521fa7c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[664ae873a521fa7c]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[aca4860da4e5a967]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7fa49fbcc9ec - rustc_query_system[b5dcdc06a735d5f1]::query::plumbing::try_execute_query::<rustc_query_impl[664ae873a521fa7c]::DynamicConfig<rustc_query_system[b5dcdc06a735d5f1]::query::caches::VecCache<rustc_span[3d5dc97049ad8d50]::def_id::LocalDefId, rustc_middle[aca4860da4e5a967]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[664ae873a521fa7c]::plumbing::QueryCtxt, false>
  30:     0x7fa49fbcc6d0 - rustc_query_impl[664ae873a521fa7c]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7fa49ff4a943 - rustc_hir_analysis[eb447668a4654582]::check_crate
  32:     0x7fa4a0154b59 - rustc_interface[fbb0cb4be6c0ba34]::passes::analysis
  33:     0x7fa4a0154575 - rustc_query_impl[664ae873a521fa7c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[664ae873a521fa7c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[aca4860da4e5a967]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7fa4a05ec766 - rustc_query_system[b5dcdc06a735d5f1]::query::plumbing::try_execute_query::<rustc_query_impl[664ae873a521fa7c]::DynamicConfig<rustc_query_system[b5dcdc06a735d5f1]::query::caches::SingleCache<rustc_middle[aca4860da4e5a967]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[664ae873a521fa7c]::plumbing::QueryCtxt, false>
  35:     0x7fa4a05ec595 - rustc_query_impl[664ae873a521fa7c]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7fa4a08ce021 - rustc_interface[fbb0cb4be6c0ba34]::interface::run_compiler::<core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>, rustc_driver_impl[7d23c5715ff089db]::run_compiler::{closure#1}>::{closure#0}
  37:     0x7fa4a08c915b - std[409886f6357001f0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[fbb0cb4be6c0ba34]::util::run_in_thread_with_globals<rustc_interface[fbb0cb4be6c0ba34]::interface::run_compiler<core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>, rustc_driver_impl[7d23c5715ff089db]::run_compiler::{closure#1}>::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>
  38:     0x7fa4a08c8fb3 - <<std[409886f6357001f0]::thread::Builder>::spawn_unchecked_<rustc_interface[fbb0cb4be6c0ba34]::util::run_in_thread_with_globals<rustc_interface[fbb0cb4be6c0ba34]::interface::run_compiler<core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>, rustc_driver_impl[7d23c5715ff089db]::run_compiler::{closure#1}>::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>::{closure#1} as core[21cdcf8e8af4c2d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7fa49bc5f6a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc7eafaff61e32df9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  40:     0x7fa49bc5f6a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6ba4a5de48dd2304
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  41:     0x7fa49bc5f6a5 - std::sys::unix::thread::Thread::new::thread_start::he469335aef763e45
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/unix/thread.rs:108:17
  42:     0x7fa49bb77609 - start_thread
  43:     0x7fa49ba9a353 - clone
  44:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.75.0 (82e1608df 2023-12-21) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground` (bin "playground")
Backtrace

The compiler backtrace is in the error message. I'm not able to get a backtrace of my own code.

@QuinnFreedman QuinnFreedman 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 Jan 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 13, 2024
@Noratrieb
Copy link
Member

Thank you for the report. This is a duplicate of #117728, which has been fixed in beta, so I'm closing this.
(next time, you could attempt to search for duplicates first by search for the file where the panic happened - but of course we'd rather have duplicates than missing reports, so don't worry if you don't :))

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2024
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 13, 2024
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

No branches or pull requests

3 participants