From 7509b428bf31bc2730231daa65a09a431c0d2cd3 Mon Sep 17 00:00:00 2001 From: Ahmed ARIF Date: Sun, 15 Mar 2026 00:20:07 +0100 Subject: [PATCH] [DBGHELP][AMD64] Return the last valid frame at end of stack in StackWalk64 --- dll/win32/dbghelp/cpu_x86_64.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/dll/win32/dbghelp/cpu_x86_64.c b/dll/win32/dbghelp/cpu_x86_64.c index e0606cdbefd..39948689091 100644 --- a/dll/win32/dbghelp/cpu_x86_64.c +++ b/dll/win32/dbghelp/cpu_x86_64.c @@ -663,9 +663,20 @@ static BOOL x86_64_stack_walk(struct cpu_stack_walk *csw, STACKFRAME64 *frame, union ctx newctx = *context; if (!fetch_next_frame(csw, &newctx, frame->AddrPC.Offset - deltapc, NULL)) - goto done_err; - frame->AddrReturn.Mode = AddrModeFlat; - frame->AddrReturn.Offset = newctx.ctx.Rip; + { + /* + * The current frame is valid, but there is no parent frame to + * report (end-of-stack). Return this frame and terminate the walk + * on the next call, which matches Windows-observed behavior. + */ + frame->AddrReturn.Mode = AddrModeFlat; + frame->AddrReturn.Offset = 0; + } + else + { + frame->AddrReturn.Mode = AddrModeFlat; + frame->AddrReturn.Offset = newctx.ctx.Rip; + } } frame->Far = TRUE;