[PATCH] Cygwin: gendef: fixed AArch64 setjmp storing incorrect frame pointer in jmpbuf

Máte Dimand <[email protected]> Fri, 3 Jul 2026 12:33:03 +0200
Newsgroups gmane.os.cygwin.patches
Message-ID <[email protected]>
This bug caused testcase "mmaptest02" to not run properly, because of the
exception handler not being ran at the last access violation, presumably
due to the frame pointer being incorrect. Fixing this allows the process
to end gracefully.

Signed-off-by: Máté Dimand <[email protected]>
---
  winsup/cygwin/scripts/gendef | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 7097da2e6..1c3218d18 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -881,7 +881,8 @@ setjmp:
      stp    x23, x24, [x0, #0x28]        // save x23, x24
      stp    x25, x26, [x0, #0x38]        // save x25, x26
      stp    x27, x28, [x0, #0x48]        // save x27, x28
-    stp    x29, x30, [x0, #0x58]        // save x29 (FP) and x30 (LR)
+    ldr    x1, [sp]            // load the previous FP from the stack
+    stp    x1, x30, [x0, #0x58]        // save previous FP and x30 (LR)

      add    x1, sp, #0x10            // get the old stack pointer
      str    x1, [x0, #0x68]            // save SP
-- 
2.50.1 (Apple Git-155)
0001-Cygwin-gendef-fixed-AArch64-setjmp-storing-incorrect.patch (text/plain, 1.3 KB)
From 138ee05ebb83b6c908b4e3efbfc671ef66a70e3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1t=C3=A9=20Dimand?= <[email protected]>
Date: Mon, 29 Jun 2026 14:47:59 +0200
Subject: [PATCH] Cygwin: gendef: fixed AArch64 setjmp storing incorrect frame
 pointer in jmpbuf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This bug caused testcase "mmaptest02" to not run properly, because of the
exception handler not being ran at the last access violation, presumably
due to the frame pointer being incorrect. Fixing this allows the process
to end gracefully.

Signed-off-by: Máté Dimand <[email protected]>
---
 winsup/cygwin/scripts/gendef | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 7097da2e6..1c3218d18 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -881,7 +881,8 @@ setjmp:
 	stp	x23, x24, [x0, #0x28]		// save x23, x24
 	stp	x25, x26, [x0, #0x38]		// save x25, x26
 	stp	x27, x28, [x0, #0x48]		// save x27, x28
-	stp	x29, x30, [x0, #0x58]		// save x29 (FP) and x30 (LR)
+	ldr	x1, [sp]			// load the previous FP from the stack
+	stp	x1, x30, [x0, #0x58]		// save previous FP and x30 (LR)
 
 	add	x1, sp, #0x10			// get the old stack pointer
 	str	x1, [x0, #0x68]			// save SP
-- 
2.50.1 (Apple Git-155)