From d9152112643b94cd43c048affd005f114e00411f Mon Sep 17 00:00:00 2001 From: pca006132 Date: Tue, 30 Jun 2020 17:13:24 +0800 Subject: [PATCH] Libunwind: patched phase1 end of stack detection. --- src/llvm_libunwind/src/Unwind-EHABI.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/llvm_libunwind/src/Unwind-EHABI.cpp b/src/llvm_libunwind/src/Unwind-EHABI.cpp index a23ba2cc..bfa4b303 100644 --- a/src/llvm_libunwind/src/Unwind-EHABI.cpp +++ b/src/llvm_libunwind/src/Unwind-EHABI.cpp @@ -446,6 +446,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except // from scratch thus achieving the same effect. __unw_init_local(cursor, uc); + uintptr_t prev_sp = 0; // Walk each frame looking for a place to stop. for (bool handlerNotFound = true; handlerNotFound;) { @@ -458,6 +459,11 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except static_cast(exception_object)); return _URC_FATAL_PHASE1_ERROR; } + uintptr_t cur_sp = _Unwind_GetGR((_Unwind_Context*)cursor, 13); + if (cur_sp == prev_sp) { + return _URC_END_OF_STACK; + } + prev_sp = cur_sp; // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) {