Skip to content

Commit

Permalink
Fix #107910, Shorten backtraces in ICEs
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed May 17, 2023
1 parent 86971ce commit 7d8b77f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions std/src/sys_common/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
}

let mut hit = false;
let mut stop = false;
backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
hit = true;

// 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 {
if let Some(sym) = symbol.name().and_then(|s| s.as_str()) {
if start && sym.contains("__rust_begin_short_backtrace") {
stop = true;
start = false;
return;
}
if sym.contains("__rust_end_short_backtrace") {
Expand All @@ -88,9 +92,6 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
res = bt_fmt.frame().symbol(frame, symbol);
}
});
if stop {
return false;
}
#[cfg(target_os = "nto")]
if libc::__my_thread_exit as *mut libc::c_void == frame.ip() {
if !hit && start {
Expand Down

0 comments on commit 7d8b77f

Please sign in to comment.