rust-lang / rust-lang/rust

ICE: impossible case reached wit gce + v0 symbol mangling

Open
#134,479 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-name-mangling C-bug F-generic_const_exprs I-ICE P-low S-bug-has-test T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Cinstrument-coverage
#![feature(generic_const_exprs)]
struct Inner<const N: usize, const M: usize>;
impl<const N: usize, const M: usize> Inner<N, M>
where
    [(); N + M]:,
{
    fn i() -> Self {
        Self
    }
}

struct Outer<const A: usize, const B: usize>(Inner<A, { B * 2 }>)
where
    [(); A + (B * 2)]:;
impl<const A: usize, const B: usize> Outer<A, B>
where
    [(); A + (B * 2)]:,
{
    fn o() -> Self {
        Self(Inner::i())
    }
}

fn main() {
    Outer::<1, 1>::o();
}

original:

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
struct Inner<const N: usize, const M: usize>;
impl<const N: usize, const M: usize> Inner<N, M> where [(); N + M]: {
    fn i() -> Self {
        Self
    }
}

struct Outer<const A: usize, const B: usize>(Inner<A, { B * 2 }>) where [(); A + (B * 2)]:;
impl<const A: usize, const B: usize> Outer<A, B> where [(); A + (B * 2)]: {
    fn o() -> Self {
        Self(Inner::i())
    }
}

fn main() {
    Outer::<1, 1>::o();
}

Version information

rustc 1.85.0-nightly (057bdb37e 2024-12-18)
binary: rustc
commit-hash: 057bdb37eccff6a2bd402509bbbadb9d73ad7bf5
commit-date: 2024-12-18
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Possibly related line of code:
https://github.com/rust-lang/rust/blob/057bdb37eccff6a2bd402509bbbadb9d73ad7bf5/compiler/rustc_symbol_mangling/src/v0.rs#L572-L584

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Cinstrument-coverage

Program output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.Vj5eJd7yWmCg/rustc_testrunner_tmpdir_reporting.hpXCYSBbyu42/mvce.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: internal compiler error: compiler/rustc_symbol_mangling/src/v0.rs:578:42: impossible case reached

thread 'rustc' panicked at compiler/rustc_symbol_mangling/src/v0.rs:578:42:
Box<dyn Any>
stack backtrace:
   0:     0x77006137164a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he51ca9b0dc91b94e
   1:     0x770061a13dbc - core::fmt::write::h2fe894f1a71f3577
   2:     0x770062989091 - std::io::Write::write_fmt::h76ab228c5bf44dde
   3:     0x7700613714a2 - std::sys::backtrace::BacktraceLock::print::h54c62b0f13f3e5cd
   4:     0x77006137399a - std::panicking::default_hook::{{closure}}::hde230593691540bb
   5:     0x7700613737e3 - std::panicking::default_hook::h93566d26810460b4
   6:     0x7700604e01e8 - std[3b55a5d72aeb08a8]::panicking::update_hook::<alloc[33b8f9c30a0f5ec3]::boxed::Box<rustc_driver_impl[d048b04913314086]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x770061374158 - std::panicking::rust_panic_with_hook::h8f04bfe0058df3f9
   8:     0x77006051ae71 - std[3b55a5d72aeb08a8]::panicking::begin_panic::<rustc_errors[84dd1c3e8f0c26d7]::ExplicitBug>::{closure#0}
   9:     0x770060510056 - std[3b55a5d72aeb08a8]::sys::backtrace::__rust_end_short_backtrace::<std[3b55a5d72aeb08a8]::panicking::begin_panic<rustc_errors[84dd1c3e8f0c26d7]::ExplicitBug>::{closure#0}, !>
  10:     0x77006050cc8d - std[3b55a5d72aeb08a8]::panicking::begin_panic::<rustc_errors[84dd1c3e8f0c26d7]::ExplicitBug>
  11:     0x770060524dd1 - <rustc_errors[84dd1c3e8f0c26d7]::diagnostic::BugAbort as rustc_errors[84dd1c3e8f0c26d7]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x770060afb9d3 - rustc_middle[c5657185550747ed]::util::bug::opt_span_bug_fmt::<rustc_span[430234a91bb838ed]::span_encoding::Span>::{closure#0}
  13:     0x770060ae133a - rustc_middle[c5657185550747ed]::ty::context::tls::with_opt::<rustc_middle[c5657185550747ed]::util::bug::opt_span_bug_fmt<rustc_span[430234a91bb838ed]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x770060ae11cb - rustc_middle[c5657185550747ed]::ty::context::tls::with_context_opt::<rustc_middle[c5657185550747ed]::ty::context::tls::with_opt<rustc_middle[c5657185550747ed]::util::bug::opt_span_bug_fmt<rustc_span[430234a91bb838ed]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x77005ebce5c0 - rustc_middle[c5657185550747ed]::util::bug::bug_fmt
  16:     0x77006105929f - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::print_const
  17:     0x77006105988a - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::path_generic_args::<<rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::default_print_def_path::{closure#3}>
  18:     0x770061057151 - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::print_def_path
  19:     0x770061057c4d - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::print_type
  20:     0x770061057365 - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::print_impl_path
  21:     0x7700610569e4 - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::print_def_path
  22:     0x7700610570e7 - <rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::SymbolMangler as rustc_middle[c5657185550747ed]::ty::print::Printer>::print_def_path
  23:     0x770061056450 - rustc_symbol_mangling[d2b91f94fa5b6f43]::v0::mangle
  24:     0x7700620c6e5f - rustc_symbol_mangling[d2b91f94fa5b6f43]::symbol_name_provider
  25:     0x7700620c58ea - rustc_query_impl[7ef989d5bbee9c2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7ef989d5bbee9c2]::query_impl::symbol_name::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c5657185550747ed]::query::erase::Erased<[u8; 16usize]>>
  26:     0x7700620c4877 - rustc_query_system[ccd0af510523da55]::query::plumbing::try_execute_query::<rustc_query_impl[7ef989d5bbee9c2]::DynamicConfig<rustc_query_system[ccd0af510523da55]::query::caches::DefaultCache<rustc_middle[c5657185550747ed]::ty::instance::Instance, rustc_middle[c5657185550747ed]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7ef989d5bbee9c2]::plumbing::QueryCtxt, false>
  27:     0x7700620c44e2 - rustc_query_impl[7ef989d5bbee9c2]::query_impl::symbol_name::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7700628254c2 - <rustc_middle[c5657185550747ed]::mir::mono::MonoItem>::symbol_name
  29:     0x770062824fbd - rustc_monomorphize[318401024c3aab57]::partitioning::assert_symbols_are_distinct::<core[d6142de48f57c781]::slice::iter::Iter<rustc_middle[c5657185550747ed]::mir::mono::MonoItem>>
  30:     0x7700620e17fd - rustc_monomorphize[318401024c3aab57]::partitioning::collect_and_partition_mono_items
  31:     0x7700620dfca4 - rustc_query_impl[7ef989d5bbee9c2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7ef989d5bbee9c2]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c5657185550747ed]::query::erase::Erased<[u8; 24usize]>>
  32:     0x7700620dfc89 - <rustc_query_impl[7ef989d5bbee9c2]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[d6142de48f57c781]::ops::function::FnOnce<(rustc_middle[c5657185550747ed]::ty::context::TyCtxt, ())>>::call_once
  33:     0x7700629b0a20 - rustc_query_system[ccd0af510523da55]::query::plumbing::try_execute_query::<rustc_query_impl[7ef989d5bbee9c2]::DynamicConfig<rustc_query_system[ccd0af510523da55]::query::caches::SingleCache<rustc_middle[c5657185550747ed]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7ef989d5bbee9c2]::plumbing::QueryCtxt, false>
  34:     0x7700629b0720 - rustc_query_impl[7ef989d5bbee9c2]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7700629f5630 - <rustc_codegen_llvm[642dbb4fc0deb88d]::LlvmCodegenBackend as rustc_codegen_ssa[f60ac56e662ca6db]::traits::backend::CodegenBackend>::codegen_crate
  36:     0x7700629e1c64 - <rustc_interface[f31e59266673035b]::queries::Linker>::codegen_and_build_linker
  37:     0x77006299b3d2 - rustc_interface[f31e59266673035b]::passes::create_and_enter_global_ctxt::<core[d6142de48f57c781]::option::Option<rustc_interface[f31e59266673035b]::queries::Linker>, rustc_driver_impl[d048b04913314086]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  38:     0x770062a15b83 - rustc_interface[f31e59266673035b]::interface::run_compiler::<(), rustc_driver_impl[d048b04913314086]::run_compiler::{closure#0}>::{closure#1}
  39:     0x770062918511 - std[3b55a5d72aeb08a8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f31e59266673035b]::util::run_in_thread_with_globals<rustc_interface[f31e59266673035b]::util::run_in_thread_pool_with_globals<rustc_interface[f31e59266673035b]::interface::run_compiler<(), rustc_driver_impl[d048b04913314086]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x7700629189a6 - <<std[3b55a5d72aeb08a8]::thread::Builder>::spawn_unchecked_<rustc_interface[f31e59266673035b]::util::run_in_thread_with_globals<rustc_interface[f31e59266673035b]::util::run_in_thread_pool_with_globals<rustc_interface[f31e59266673035b]::interface::run_compiler<(), rustc_driver_impl[d048b04913314086]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d6142de48f57c781]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x770062919f6f - std::sys::pal::unix::thread::Thread::new::thread_start::he7ac21643e42d931
  42:     0x77005cca339d - <unknown>
  43:     0x77005cd2849c - <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: rustc 1.85.0-nightly (057bdb37e 2024-12-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -C instrument-coverage -Z dump-mir-dir=dir

query stack during panic:
#0 [symbol_name] computing the symbol for `<impl at /tmp/icemaker_global_tempdir.Vj5eJd7yWmCg/rustc_testrunner_tmpdir_reporting.hpXCYSBbyu42/mvce.rs:3:1: 5:18>::i`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 1 warning emitted


@rustbot label +F-generic_const_exprs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reduced case from a.rs with rustc -Cinstrument-coverage, then inspect compiler/rustc_symbol_mangling/src/v0.rs around line 578 and the print_const path named in the stack trace. Done means this input no longer reaches the internal compiler error and regression coverage exercises the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.