[PATCH] Cygwin: gendef: fix AArch64 stabilize_sig_stack lock retry
Aswin Kalies Ramkumar Mangayarkarasi
aswin.kalies@multicorewareinc.com
Tue Sep 22 20:27:54 GMT 2026
Hi Everyone,
The AArch64 stabilize_sig_stack retry label sits below the code that
computes the stacklock address and loads the "locked" constant, so
neither is recomputed on a retry. The signal-handler path branches
back to that label after reusing x9 and x12 for the incyg counter, so
a retry can operate on incyg instead of stacklock. Move the label
above the setup, and clear the exclusive monitor before yielding, as
the ldaxr otherwise leaves one open across the yield.
Thanks and Regards,
Aswin Kalies
Inline patch:
---
winsup/cygwin/scripts/gendef | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 5f25c543e..b8684def7 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -495,11 +495,13 @@ stabilize_sig_stack:
ldr x10, [x18, #0x8] // load TLS block base pointer into x10
- // try to acquire the lock
+ // try to acquire the lock. The address and the "locked" constant are
+ // recomputed on every iteration: the signal-handler path below branches
+ // back here after using x9/x12 for the incyg counter.
+1:
mov w9, #1 // value to store (1 == locked)
ldr x11, =_cygtls.stacklock // load the symbol offset
add x12, x10, x11 // x12 = tls_base + &stacklock
-1:
ldaxr w13, [x12] // load old lock value
cbnz w13, 2f // if already locked, wait
stxr w14, w9, [x12] // attempt to acquire the lock
@@ -507,6 +509,7 @@ stabilize_sig_stack:
b 3f // lock acquired, continue
2:
+ clrex // drop the exclusive monitor
yield // yield to allow other threads to run
b 1b // retry acquiring the lock
--
2.49.0.windows.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cygwin-gendef-fix-AArch64-stabilize_sig_stack-lock-retry.patch
Type: application/octet-stream
Size: 2008 bytes
Desc: Cygwin-gendef-fix-AArch64-stabilize_sig_stack-lock-retry.patch
URL: <https://cygwin.com/pipermail/cygwin-patches/attachments/20260922/072e2a75/attachment.obj>
More information about the Cygwin-patches
mailing list