Skip to content

Commit 75ae769

Browse files
committed
Windows AArch64: Break out of tracing when no longer making progress
1 parent adc9f5c commit 75ae769

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/backtrace/dbghelp64.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
8989
let mut context = core::mem::zeroed::<MyContext>();
9090
RtlCaptureContext(&mut context.0);
9191

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

118+
let previous_ip = context.ip();
119+
let previous_sp = context.sp();
117120
let mut handler_data = 0usize;
118121
let mut establisher_frame = 0;
119122

@@ -127,5 +130,9 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
127130
&mut establisher_frame,
128131
ptr::null_mut(),
129132
);
133+
134+
if context.ip() == 0 || (context.ip() == previous_ip && context.sp() == previous_sp) {
135+
break;
136+
}
130137
}
131138
}

0 commit comments

Comments
 (0)