-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-backtraceArea: BacktracesArea: BacktracesA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
right now, nearly all foo.expect("bar") backtraces start like this:
stack backtrace:
0: rust_begin_unwind
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/panicking.rs:72:14
2: core::panicking::panic_display
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/panicking.rs:256:5
3: core::panicking::panic_str
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/panicking.rs:231:5
4: core::option::expect_failed
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/option.rs:1994:5
5: core::option::Option<T>::expect
at /rustc/7f2fc33da6633f5a764ddc263c769b6b2873d167/library/core/src/option.rs:895:21
this is not super useful. it doesn't add any information, other than maybe the very last frame which says you called expect(). it would be nice to omit anything in the core::panicking module from the backtrace; and maybe expect_failed and the core::ops::function::FnOnce::call_once that show up at the end of the backtrace as well. people can always opt back in with RUST_BACKTRACE=full.
the code for this lives in
rust/library/std/src/sys_common/backtrace.rs
Lines 77 to 81 in 378a43a
| // Any frames between `__rust_begin_short_backtrace` and `__rust_end_short_backtrace` | |
| // are omitted from the backtrace in short mode, `__rust_end_short_backtrace` will be | |
| // called before the panic hook, so we won't ignore any frames if there is no | |
| // invoke of `__rust_begin_short_backtrace`. | |
| if print_fmt == PrintFmt::Short { |
@rustbot label +T-libs +A-runtime
kpreid, est31, 0rvar, Rigidity, yonikremer and 4 more
Metadata
Metadata
Assignees
Labels
A-backtraceArea: BacktracesArea: BacktracesA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.