https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=83afe3e238cd12fb7d4799ba6b3c77e9e3618d91
commit 83afe3e238cd12fb7d4799ba6b3c77e9e3618d91 Author: Takashi Yano <[email protected]> Date: Tue Jan 21 00:13:04 2025 +0900 Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent The commit a22a0ad7c4f0 was not entirely correct. Even with the patch, some hangs still occur. This patch overrides the previous commit along with the patch that makes cygwait() reentrant, to fix these hangs. Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256987.html Fixes: d243e51ef1d3 ("Cygwin: signal: Fix deadlock between main thread and sig thread") Fixes: a22a0ad7c4f0 ("Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent") Reported-by: Daisuke Fujimura <[email protected]> Reported-by: Jeremy Drake <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> Diff: --- winsup/cygwin/sigproc.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index ba7818a68..1ffe00a94 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -742,6 +742,9 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) memcpy (p, si._si_commune._si_str, n); p += n; } + unsigned cw_mask; + cw_mask = pack.si.si_signo == __SIGFLUSHFAST ? 0 : cw_sig_restart; + DWORD nb; BOOL res; /* Try multiple times to send if packsize != nb since that probably @@ -751,8 +754,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) res = WriteFile (sendsig, leader, packsize, &nb, NULL); if (!res || packsize == nb) break; - if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED) - _my_tls.call_signal_handler (); + cygwait (NULL, 10, cw_mask); res = 0; } @@ -785,7 +787,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) if (wait_for_completion) { sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup); - rc = cygwait (pack.wakeup, WSSC); + rc = cygwait (pack.wakeup, WSSC, cw_mask); ForceCloseHandle (pack.wakeup); } else @@ -806,9 +808,6 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) rc = -1; } - if (wait_for_completion && si.si_signo != __SIGFLUSHFAST) - _my_tls.call_signal_handler (); - out: if (communing && rc) {
