[newlib-cygwin/cygwin-3_5-branch] Cygwin: cygfe: Fix a bug that signal handler destroys fpu states
Takashi Yano
tyan0@sourceware.org
Thu Oct 31 20:00:11 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ea01b87f0f43068fd69658725268ec403ad3b5e9
commit ea01b87f0f43068fd69658725268ec403ad3b5e9
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Thu Oct 31 15:47:35 2024 +0900
Cygwin: cygfe: Fix a bug that signal handler destroys fpu states
Previously, sigfe had a long-standing problem that the signal handler
destroys fpu states. This is caused by fninit instruction in sigdelayed.
With this patch, instead of fnstcw/fldcw and fninit, fnstenv/fldenv
are used to maintain fpu states.
Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256503.html
Fixes: ed89fbc3ff11 ("* gendef (sigdelayed (x86_64)): Save and restore FPU control word.")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diff:
---
winsup/cygwin/release/3.5.5 | 3 +++
winsup/cygwin/scripts/gendef | 15 +++++++--------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/winsup/cygwin/release/3.5.5 b/winsup/cygwin/release/3.5.5
index dbd6b026b..9cc51dc2e 100644
--- a/winsup/cygwin/release/3.5.5
+++ b/winsup/cygwin/release/3.5.5
@@ -27,3 +27,6 @@ Fixes:
- Restore pipe blocking mode for non-cygwin apps.
Addresses: https://github.com/git-for-windows/git/issues/5115
+
+- Fix a problem that signal handler destroys the FPU context.
+ Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256503.html
diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 3b1f8b9da..c2ad5c75e 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -213,10 +213,10 @@ sigdelayed:
.seh_pushreg %rbx
pushq %rax
.seh_pushreg %rax
- subq \$0x128,%rsp
- .seh_stackalloc 0x128
- stmxcsr 0x124(%rsp)
- fnstcw 0x120(%rsp)
+ subq \$0x148,%rsp
+ .seh_stackalloc 0x148
+ stmxcsr 0x13c(%rsp)
+ fnstenv 0x120(%rsp)
movdqa %xmm15,0x110(%rsp)
movdqa %xmm14,0x100(%rsp)
movdqa %xmm13,0xf0(%rsp)
@@ -275,10 +275,9 @@ sigdelayed:
movdqa 0xf0(%rsp),%xmm13
movdqa 0x100(%rsp),%xmm14
movdqa 0x110(%rsp),%xmm15
- fninit
- fldcw 0x120(%rsp)
- ldmxcsr 0x124(%rsp)
- addq \$0x128,%rsp
+ fldenv 0x120(%rsp)
+ ldmxcsr 0x13c(%rsp)
+ addq \$0x148,%rsp
popq %rax
popq %rbx
popq %rcx
More information about the Cygwin-cvs
mailing list