Skip to content

Commit

Permalink
Windows AArch64: Break out of tracing when no longer making progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaoliello committed Apr 9, 2024
1 parent adc9f5c commit 75ae769
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/backtrace/dbghelp64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
let mut context = core::mem::zeroed::<MyContext>();
RtlCaptureContext(&mut context.0);

// Call `RtlVirtualUnwind` to find the previous stack frame, walking until we hit ip = 0.
while context.ip() != 0 {
// Call `RtlVirtualUnwind` to find the previous stack frame, walking until we hit ip = 0
// or we are no longer making progress.
loop {
// The base address of the module containing the function will be stored here
// when RtlLookupFunctionEntry returns successfully.
let mut base = 0;
Expand All @@ -114,6 +115,8 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
break;
}

let previous_ip = context.ip();
let previous_sp = context.sp();
let mut handler_data = 0usize;
let mut establisher_frame = 0;

Expand All @@ -127,5 +130,9 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
&mut establisher_frame,
ptr::null_mut(),
);

if context.ip() == 0 || (context.ip() == previous_ip && context.sp() == previous_sp) {
break;
}
}
}

0 comments on commit 75ae769

Please sign in to comment.