4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 18:19:08 +08:00

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>
This commit is contained in:
Takashi Yano 2024-10-31 15:47:35 +09:00
parent 2962922d03
commit ea01b87f0f
2 changed files with 10 additions and 8 deletions

View File

@ -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

View File

@ -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