-
Notifications
You must be signed in to change notification settings - Fork 13k
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
RUST_BACKTRACE=1 panic output still includes functions called by panic! #58554
Comments
Backtraces printed by panic still contain frames that are internal details, and are not relevant to the panic. This lowers signal to noise ratio of the backtrace and makes it hard to notice where the actual panic is. fn main() {
panic!()
} Prints 24 frames, and only 1 of them is in user code.
I'd expect the backtrace to at least omit the first 12 frames (0 to 11) after |
One idea is to find the first occurrence of We'd have to be careful to show all frames if Also, we'd have to make sure that we show use std::fmt;
struct S;
impl fmt::Display for S {
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
panic!("panic2")
}
}
fn main() {
panic!("panic1: {}", S)
} |
I using std::panic::set_hook capure and filter errors |
Could you maybe post your hook here or in a gist? I'm getting SIGILL for just trying the example in the docs and I'm about to tear my eyes out if I have to see more spam dumps.
|
You should not call unwrap on the set_hook callback |
I'm new to the rustc codebase, but it seems like something akin to this could work: let skipped_before = frames.iter().position(|frame|
unimplemented!("somehow determine whether `frame` is a call to `begin_panic`")
).map(|i|
// Exclude the call to `begin_panic()` as well.
i + 1
).unwrap_or(0); This should still include the |
@ehuss Thank you, I just switched to |
I'm going to close this as fixed. A backtrace from main now looks like this:
|
RUST_BACKTRACE=1
panic output still includes the functions called by thepanic!
macro. This was previously reported in #37783 but, in the merged fix, only the functions beforemain
were removed. This makes it harder to determine which function the panic occurred in.In
filter_frames
,skipped_before
is always0
.The text was updated successfully, but these errors were encountered: