Skip to content

Commit 71fbd6e

Browse files
Exit unwinding early when at the top of the stack and additional info won't be found.
Summary: This patch follows libgcc's lead: When the return-address register is zero, there won't be additional stack frames to examine, or gather information about. Exit before spending time looking for something known not to be found. Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77099
1 parent f444806 commit 71fbd6e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,12 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
18481848
pc &= (pint_t)~0x1;
18491849
#endif
18501850

1851+
// Exit early if at the top of the stack.
1852+
if (pc == 0) {
1853+
_unwindInfoMissing = true;
1854+
return;
1855+
}
1856+
18511857
// If the last line of a function is a "throw" the compiler sometimes
18521858
// emits no instructions after the call to __cxa_throw. This means
18531859
// the return address is actually the start of the next function.

0 commit comments

Comments
 (0)