From 30207aa25c7d0ca25447c6bc95c4f451a4573a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 12 Nov 2024 12:13:47 +0100 Subject: [PATCH] Stackwalk safety fix. Stackwalk logic fix (although probably not very important) --- Core/MIPS/MIPSStackWalk.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/MIPS/MIPSStackWalk.cpp b/Core/MIPS/MIPSStackWalk.cpp index 065e211e02..446c31d6c9 100644 --- a/Core/MIPS/MIPSStackWalk.cpp +++ b/Core/MIPS/MIPSStackWalk.cpp @@ -113,6 +113,7 @@ namespace MIPSStackWalk { stop = start - LONGEST_FUNCTION; } for (u32 pc = start; Memory::IsValidAddress(pc) && pc >= stop; pc -= 4) { + _dbg_assert_(Memory::IsValidAddress(pc)); MIPSOpcode op = Memory::Read_Instruction(pc, true); // Here's where they store the ra address. @@ -162,7 +163,7 @@ namespace MIPSStackWalk { } } - std::vector Walk(u32 pc, u32 ra, u32 sp, u32 threadEntry, u32 threadStackTop) { + std::vector Walk(const u32 pc, u32 ra, u32 sp, const u32 threadEntry, u32 threadStackTop) { std::vector frames; if (!Memory::IsValidAddress(pc) || !Memory::IsValidAddress(sp) || !Memory::IsValidAddress(ra)) { @@ -176,7 +177,7 @@ namespace MIPSStackWalk { current.stackSize = -1; u32 prevEntry = INVALIDTARGET; - while (pc != threadEntry) { + while (current.pc != threadEntry) { if (!Memory::IsValidAddress(current.pc)) { break; }