[all-commits] [llvm/llvm-project] 0d819a: [libunwind] Fix aarch64 SEH unwinding with a debug...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Fri Oct 17 05:20:22 PDT 2025


  Branch: refs/heads/release/21.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d819a9104b28f4fdd459d55d96228d78dc93a0d
      https://github.com/llvm/llvm-project/commit/0d819a9104b28f4fdd459d55d96228d78dc93a0d
  Author: Martin Storsjö <martin at martin.st>
  Date:   2025-10-17 (Fri, 17 Oct 2025)

  Changed paths:
    M libunwind/src/Unwind-seh.cpp

  Log Message:
  -----------
  [libunwind] Fix aarch64 SEH unwinding with a debugger attached (#162867)

See https://github.com/LuaJIT/LuaJIT/issues/593#issuecomment-1717728494
for the original explanation of the problem.

In short; when a debugger is attached, there's a
function KiUserExceptionDispatcher in the stack that is being unwound.
The function KiUserExceptionDispatcher contains a CONTEXT, with a copy
of the context from where the exception was raised. When unwinding
through this function, this whole CONTEXT gets restored.

This CONTEXT is what we receive a pointer to in the callbacks, as the
ms_ctx pointer.

When we unwind manually using RtlUnwindEx, the unwinding overwrites the
CONTEXT that is passed to it. Thus, to avoid clobbering the CONTEXT that
needs to be restored by KiUserExceptionDispatcher, we could either
declare a new temporary CONTEXT on the stack before calling RtlUnwindEx,
or just use disp->ContextRecord as we already have available.

Fixes: https://github.com/llvm/llvm-project/issues/161851

Co-authored-by: Peter Cawley <corsix at corsix.org>
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>
(cherry picked from commit a17afee7ec41e53292f074fc967d264452e4363b)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list