From 8bedc80cafee0bee0c93eb7290a9967f1dbbffa4 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Fri, 24 Nov 2023 15:04:19 -0800 Subject: [PATCH] [Zion] Add a max depth to stack unwinds. --- zion/common/stack_unwind.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zion/common/stack_unwind.cpp b/zion/common/stack_unwind.cpp index 4bdbc10..1229b8a 100644 --- a/zion/common/stack_unwind.cpp +++ b/zion/common/stack_unwind.cpp @@ -9,12 +9,14 @@ bool IsValid(uint64_t* rbp) { return rbp && *rbp != kStackBaseSentinel; } } // namespace void StackUnwind(uint64_t rbp) { + uint64_t depth_limit = 10; dbgln("-- Begin Stack --"); uint64_t* rbp_ptr = reinterpret_cast(rbp); - while (IsValid(rbp_ptr)) { + while (IsValid(rbp_ptr) && depth_limit > 0) { uint64_t rip = *(rbp_ptr + 1); dbgln("RIP: {x}", rip); rbp_ptr = reinterpret_cast(*rbp_ptr); + depth_limit--; } dbgln("-- End Stack --"); }