Skip to content

Commit 26c9126

Browse files
Abseil Teamcopybara-github
authored andcommitted
Fix a corner case in the aarch64 unwinder
In case of two nested back-to-back signals (such as what happens in NestedSignal test) we could end up erroneously using the frame pointer from ucontext_t twice, leading to premature backtrace termination. In the situation where this happens, the call stack looks like #0 <unwinder frames> #1 SigUsr2Handler #2 __kernel_rt_sigreturn #3 raise #4 SigUsr1Handler #5 __kernel_rt_sigreturn #6 raise #7 RaiseSignal ... When unwinding from #2, we get the fp value from the ucontext (as we should). However, because raise does not modify the fp and because SigUsr1Handler is also a signal handler, when we try to unwind from #4 (#3 is skipped), NextStackFrame ends up looking at the ucontext fp again, and comparing it with the previous (identical) FP value. Non-strict equality accepts this as a valid frame, but the unwinder later bails out due to a zero-sized frame. Using a strict equality causes NextStackFrame to reject the ucontext fp and use the FP from FP chain instead. This causes us to skip a few more frames, but at least we continue to unwind instead of giving up. In this case, the computed backtrace skips functions #3, #4 and #6. PiperOrigin-RevId: 804308754 Change-Id: I5d43e6bea80e4abff1075ada03782ae11c599161
1 parent 7fc86c6 commit 26c9126

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

absl/debugging/internal/stacktrace_aarch64-inl.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void **NextStackFrame(void **old_frame_pointer, const void *uc,
123123
// earlier in the stack than the old_frame_pointer, then use it. If it is
124124
// later, then we have already unwound through it and it needs no special
125125
// handling.
126-
if (pre_signal_frame_pointer >= old_frame_pointer) {
126+
if (pre_signal_frame_pointer > old_frame_pointer) {
127127
new_frame_pointer = pre_signal_frame_pointer;
128128
}
129129
}

0 commit comments

Comments
 (0)