Skip to content

Commit 4fbceca

Browse files
committed
Cygwin: signal: Clear direction flag in sigdeleyed
x86_64 ABI requires the direction flag in CPU flags register cleared. https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions However, currently that flag is not maintained in signal handler. Therefore, if the signal handler is called when that flag is set, it destroys the data and may crash if rep instruction is used in the signal handler. With this patch, the direction flag is cleared in sigdelayed() by adding cld instruction. Backported-from: d71aecc (Cygwin: signal: Clear direction flag in sigdeleyed, 2025-03-24) Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257704.html Fixes: 1fd5e00 ("import winsup-2000-02-17 snapshot") Reported-by: Christian Franke <[email protected]> Reviewed-by: Corinna Vischen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 9f4cec47df66a913256912c358afe5e597dec25c) Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5c97a05 commit 4fbceca

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

winsup/cygwin/release/3.6.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ Fixes:
33

44
- Console mode is really restored to the previous mode.
55
Addresses: https://github.com/msys2/msys2-runtime/issues/268
6+
7+
- Clear direction flag in sigdeleyed before calling signal handler.
8+
Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257704.html

winsup/cygwin/scripts/gendef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ sigdelayed:
179179
movq %rsp,%rbp
180180
pushf
181181
.seh_pushreg %rax # fake, there's no .seh_pushreg for the flags
182+
cld # x86_64 ABI requires direction flag cleared
182183
# stack is aligned or unaligned on entry!
183184
# make sure it is aligned from here on
184185
# We could be called from an interrupted thread which doesn't know

0 commit comments

Comments
 (0)