Skip to content

ICE on trying to debug format type #77458

Closed

Description

@bjorn3

Code

Run format!("{:?}", ty) where ty is a rustc_middle::ty::Ty.

Meta

Happens since #73996. This makes rustc_codegen_cranelift ICE as it uses format!("{:?}", ty) to get the symbol name for vtables. Using -Ztrim-diagnostic-paths=no can be used as workaround.

rustc --version --verbose:

rustc 1.48.0-nightly (8fe73e80d 2020-10-01)
binary: rustc
commit-hash: 8fe73e80d762bc575040239fc05fb1c612873554
commit-date: 2020-10-01
host: x86_64-unknown-linux-gnu
release: 1.48.0-nightly
LLVM version: 11.0

Error output

Backtrace

error: internal compiler error: trimmed_def_paths constructed
  |
  = note: delayed at    0: rustc_errors::Handler::delay_good_path_bug
             1: rustc_middle::ty::print::pretty::trimmed_def_paths
             2: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::trimmed_def_paths>::compute
             3: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
             4: rustc_data_structures::stack::ensure_sufficient_stack
             5: rustc_query_system::query::plumbing::get_query_impl
             6: <rustc_middle::ty::print::pretty::FmtPrinter<F> as rustc_middle::ty::print::Printer>::print_def_path
             7: rustc_middle::ty::print::pretty::PrettyPrinter::pretty_print_type
             8: <rustc_middle::ty::print::pretty::FmtPrinter<F> as rustc_middle::ty::print::Printer>::print_type
             9: rustc_middle::ty::print::pretty::<impl core::fmt::Display for &rustc_middle::ty::TyS>::fmt
            10: core::fmt::write
            11: alloc::fmt::format
            12: rustc_codegen_cranelift::intrinsics::codegen_intrinsic_call
            13: rustc_codegen_cranelift::abi::codegen_terminator_call
            14: rustc_codegen_cranelift::base::codegen_fn_content
            15: rustc_session::utils::<impl rustc_session::session::Session>::time
            16: rustc_codegen_cranelift::base::trans_fn
            17: rustc_codegen_cranelift::driver::codegen_mono_items
            18: rustc_codegen_cranelift::driver::aot::module_codegen
            19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
            20: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
            21: rustc_session::utils::<impl rustc_session::session::Session>::time
            22: rustc_codegen_cranelift::driver::time
            23: rustc_codegen_cranelift::driver::aot::run_aot
            24: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
            25: rustc_session::utils::<impl rustc_session::session::Session>::time
            26: rustc_interface::passes::QueryContext::enter
            27: rustc_interface::queries::Queries::ongoing_codegen
            28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
            29: rustc_span::with_source_map
            30: scoped_tls::ScopedKey<T>::set
            31: std::sys_common::backtrace::__rust_begin_short_backtrace
            32: core::ops::function::FnOnce::call_once{{vtable.shim}}
            33: std::sys::unix::thread::Thread::new::thread_start
            34: start_thread
            35: clone
          

thread 'rustc' panicked at 'no warnings or errors encountered even though `delayed_good_path_bugs` issued', compiler/rustc_errors/src/lib.rs:961:13
stack backtrace:
   0: rust_begin_unwind
   1: std::panicking::begin_panic_fmt
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place
   7: rustc_span::with_source_map
   8: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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.48.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C embed-bitcode=no -C debuginfo=0 -C debug-assertions=off --crate-type lib

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

query stack during panic:
end of query stack
error: could not compile `cc`.

To learn more, run the command again with --verbose.
command did not execute successfully: "/home/bjorn/Documenten/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "1" "--release" "--features" " max_level_info" "--manifest-path" "/home/bjorn/Documenten/rust/compiler/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
failed to run: /home/bjorn/Documenten/rust/build/bootstrap/debug/bootstrap build -j 1
Build completed unsuccessfully in 0:00:02

@rustbot modify labels: +requires-nightly

Activity

  1. added
    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.
    on Oct 2, 2020
  2. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Oct 2, 2020
  3. added
    A-fmtArea: `core::fmt`
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 4, 2020
  4. added
    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to Rust
    on Oct 4, 2020
  5. da-x commented on Oct 4, 2020

    @da-x
    Member

    Are you sure it is {:?}? I'm asking because I see core::fmt::Display in the backtrace, where I'd expected the Debug trait. Point perhaps to the specific format!() in rustc_codegen_cranelift that triggers this?

  6. bjorn3 commented on Oct 4, 2020

    @bjorn3
    MemberAuthor

    Ah my bad. It is indeed {}. The panic comes from one of the following three identical format! invocations: https://github.com/bjorn3/rustc_codegen_cranelift/blob/c0507a63fb30a14ea7b819af8241b6555d4ffea8/src/intrinsics/mod.rs#L819-L847

  7. apiraino commented on Oct 7, 2020

    @apiraino
    Contributor

    Assigning P-low as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

  8. added
    P-lowLow priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 7, 2020
  9. wesleywiser commented on Nov 6, 2020

    @wesleywiser
    Member

    Removing the regression label because this is actually a bug with the formatting implementation for a rustc internal type and isn't user impacting in anyway.

  10. bjorn3 commented on Dec 15, 2022

    @bjorn3
    MemberAuthor

    rustc_middle::ty::print::with_no_trimmed_paths!({ ... }) can be used to avoid this panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustA-fmtArea: `core::fmt`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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions