Skip to content

backtraces from debug assertion rustc are very slow #158969

Description

@matthiaskrgr

given an ice like

fn main() {
    break rust;
}

running rustc on it and getting the backtrace takes around 0.072 seconds.

with debug assertions, it takes around 6.5 seconds which is around 90 times slower which is surprising.
I don't know since when this is happening but my gut says its probably recent.

There is a noticeable pause after

thread 'rustc' (482933) panicked at /rustc-dev/f10db292a3733b5c67c8da8c7661195ff4b05774/compiler/rustc_hir_typeck/src/lib.rs:697:10:
Box<dyn Any>
stack backtrace:

right before it prints the actual backtraces 🤔

timings:

time:   0.000; rss:  112MB ->  114MB (   +2MB)	parse_crate
time:   0.000; rss:  122MB ->  123MB (   +1MB)	crate_injection
time:   0.004; rss:  123MB ->  134MB (  +11MB)	expand_crate
time:   0.004; rss:  123MB ->  134MB (  +11MB)	macro_expand_crate
time:   0.000; rss:  134MB ->  135MB (   +1MB)	AST_validation
time:   0.000; rss:  135MB ->  135MB (   +0MB)	compute_effective_visibilities
time:   0.000; rss:  135MB ->  135MB (   +0MB)	finalize_macro_resolutions
time:   0.021; rss:  135MB ->  166MB (  +30MB)	late_resolve_crate
error[E0425]: cannot find value `rust` in this scope
 --> a.rs:2:11
  |
2 |     break rust;
  |           ^^^^ not found in this scope

time:   0.000; rss:  166MB ->  166MB (   +0MB)	resolve_report_errors
time:   0.022; rss:  135MB ->  166MB (  +31MB)	resolve_crate
time:   0.000; rss:  169MB ->  170MB (   +0MB)	looking_for_entry_point
time:   0.000; rss:  170MB ->  170MB (   +0MB)	check_externally_implementable_items
time:   0.000; rss:  170MB ->  170MB (   +0MB)	looking_for_derive_registrar
time:   0.000; rss:  170MB ->  170MB (   +0MB)	unused_lib_feature_checking
time:   0.000; rss:  169MB ->  170MB (   +0MB)	misc_checking_1
time:   0.002; rss:  170MB ->  178MB (   +8MB)	coherence_checking
error[E0268]: `break` outside of a loop or labeled block
 --> a.rs:2:5
  |
2 |     break rust;
  |     ^^^^^^^^^^ cannot `break` outside of a loop or labeled block

error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?
 --> a.rs:2:5
  |
2 |     break rust;
  |     ^^^^^^^^^^
  |
  = note: the compiler expectedly panicked. this is a feature.
  = note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675
  = note: rustc 1.99.0-nightly (f10db292a 2026-07-07) running on x86_64-unknown-linux-gnu
  = note: compiler flags: -Z time-passes


thread 'rustc' (483179) panicked at /rustc-dev/f10db292a3733b5c67c8da8c7661195ff4b05774/compiler/rustc_hir_typeck/src/lib.rs:697:10:
Box<dyn Any>
stack backtrace:
   0:     0x7f11f7dff9c0 - std[c8053079d20a6ade]::backtrace_rs::backtrace::libunwind::trace
                               at /rustc/f10db292a3733b5c67c8da8c7661195ff4b05774/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
   1:     0x7f11f7dff9c0 - std[c8053079d20a6ade]::backtrace_rs::backtrace::trace_unsynchronized::<std[c8053079d20a6ade]::sys::backtrace::_print_fmt::{closure#1}>
                               at /rustc/f10db292a3733b5c67c8da8c7661195ff4b05774/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
...
...
...
 141:     0x7f11f7dfb4df - <std[c8053079d20a6ade]::sys::thread::unix::Thread>::new::thread_start
                               at /rustc/f10db292a3733b5c67c8da8c7661195ff4b05774/library/std/src/sys/thread/unix.rs:123:17
 142:     0x7f11f1c981b9 - <unknown>
 143:     0x7f11f1d1d21c - <unknown>
 144:                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: please attach the file at `/tmp/im/bt/rustc-ice-2026-07-08T18_33_46-483177.txt` to your bug report

note: rustc 1.99.0-nightly (f10db292a 2026-07-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z time-passes

query stack during panic:
#0 [typeck_root] type-checking `main`
#1 [analysis] running analysis passes on crate `a`
end of query stack
time:   6.153; rss:  170MB -> 1946MB (+1776MB)	type_check_crate
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0268, E0425.
For more information about an error, try `rustc --explain E0268`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-libs-nominatedNominated for discussion during a libs team meeting.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions