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 <[email protected]>
Reviewed-by:
Signed-off-by: Takashi Yano <[email protected]>
---
winsup/cygwin/scripts/gendef | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
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
--
2.45.1