Skip to content

Commit 7d8b77f

Browse files
committed
Fix #107910, Shorten backtraces in ICEs
1 parent 86971ce commit 7d8b77f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

std/src/sys_common/backtrace.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
6868
}
6969

7070
let mut hit = false;
71-
let mut stop = false;
7271
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
7372
hit = true;
73+
74+
// Any frames between `__rust_begin_short_backtrace` and `__rust_end_short_backtrace`
75+
// are omitted from the backtrace in short mode, `__rust_end_short_backtrace` will be
76+
// called before the panic hook, so we won't ignore any frames if there is no
77+
// invoke of `__rust_begin_short_backtrace`.
7478
if print_fmt == PrintFmt::Short {
7579
if let Some(sym) = symbol.name().and_then(|s| s.as_str()) {
7680
if start && sym.contains("__rust_begin_short_backtrace") {
77-
stop = true;
81+
start = false;
7882
return;
7983
}
8084
if sym.contains("__rust_end_short_backtrace") {
@@ -88,9 +92,6 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
8892
res = bt_fmt.frame().symbol(frame, symbol);
8993
}
9094
});
91-
if stop {
92-
return false;
93-
}
9495
#[cfg(target_os = "nto")]
9596
if libc::__my_thread_exit as *mut libc::c_void == frame.ip() {
9697
if !hit && start {

0 commit comments

Comments
 (0)