From 5f14b6357b8fefcd390f52b0c7a50790e5361976 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Mon, 18 May 2020 15:16:29 +0300 Subject: [PATCH] ntdll: Properly restore x29/x30 for arm64 packed unwind data with local stack. For the CR == 3 case, x29/x30 should be restored from x29, not from sp, which may have been decremented further for local stack storage. This fixes uwinding the stack for C++ exceptions in code generated by MSVC. Signed-off-by: Martin Storsjo Signed-off-by: Alexandre Julliard --- dlls/ntdll/signal_arm64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index e81ea8f82e1..4c5944759fd 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -1558,7 +1558,12 @@ static void *unwind_packed_data( ULONG_PTR base, ULONG_PTR pc, RUNTIME_FUNCTION if (!skip) { - if (func->u.s.CR == 3) restore_regs( 29, 2, 0, context, ptrs ); + if (func->u.s.CR == 3) + { + DWORD64 *fp = (DWORD64 *) context->u.s.Fp; /* u.X[29] */ + context->u.X[29] = fp[0]; + context->u.X[30] = fp[1]; + } context->Sp += local_size; if (fp_size) restore_fpregs( 8, fp_size / 8, int_size, context, ptrs ); if (func->u.s.CR == 1) restore_regs( 30, 1, int_size - 8, context, ptrs );