msys2-runtime: backport signal hang fix
See https://github.com/msys2/msys2-runtime/pull/251
This commit is contained in:
parent
6de1975626
commit
0af6f79367
@ -0,0 +1,88 @@
|
||||
From 33799c250f0a7d353cfc34961c7bba26d3a4219a Mon Sep 17 00:00:00 2001
|
||||
From: Takashi Yano <takashi.yano@nifty.ne.jp>
|
||||
Date: Mon, 23 Dec 2024 10:33:25 +0900
|
||||
Subject: [PATCH 45/N] Cygwin: signal: Do not handle signal when
|
||||
__SIGFLUSHFAST is sent
|
||||
|
||||
After the commit d243e51ef1d3, zsh sometimes hangs at startup. This
|
||||
occurs because SIGCHLD, which should trigger sigsuspend(), is handled
|
||||
in cygwait() that is used to wait for a wakeup event in sig_send(),
|
||||
even when __SIGFLUSHFAST is sent. Despite __SIGFLUSHFAST being
|
||||
required to return before handling the signal, this does not happen.
|
||||
With this patch, if the signal currently being sent is __SIGFLUSHFAST,
|
||||
do not handle the received signal and keep it asserted after the
|
||||
cygwait() for the wakeup event. Apply the same logic to the cygwait()
|
||||
in the retrying loop for WriteFile() as well.
|
||||
|
||||
Applied-from: https://inbox.sourceware.org/cygwin-patches/20241223013332.1269-1-takashi.yano@nifty.ne.jp
|
||||
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html
|
||||
Fixes: d243e51ef1d3 ("Cygwin: signal: Fix deadlock between main thread and sig thread")
|
||||
Reported-by: Daisuke Fujimura <booleanlabel@gmail.com>
|
||||
Reviewed-by:
|
||||
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
||||
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
||||
---
|
||||
winsup/cygwin/release/3.5.6 | 5 +++++
|
||||
winsup/cygwin/sigproc.cc | 20 +++++++++++++++-----
|
||||
2 files changed, 20 insertions(+), 5 deletions(-)
|
||||
create mode 100644 winsup/cygwin/release/3.5.6
|
||||
|
||||
diff --git a/winsup/cygwin/release/3.5.6 b/winsup/cygwin/release/3.5.6
|
||||
new file mode 100644
|
||||
index 0000000..643d58e
|
||||
--- /dev/null
|
||||
+++ b/winsup/cygwin/release/3.5.6
|
||||
@@ -0,0 +1,5 @@
|
||||
+Fixes:
|
||||
+------
|
||||
+
|
||||
+- Fix zsh hang at startup.
|
||||
+ Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html
|
||||
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
|
||||
index cf43aa9..c298527 100644
|
||||
--- a/winsup/cygwin/sigproc.cc
|
||||
+++ b/winsup/cygwin/sigproc.cc
|
||||
@@ -751,10 +751,14 @@ 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)
|
||||
+ if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED
|
||||
+ && pack.si.si_signo != __SIGFLUSHFAST)
|
||||
_my_tls.call_signal_handler ();
|
||||
res = 0;
|
||||
}
|
||||
+ /* Re-assert signal_arrived which has been cleared in cygwait(). */
|
||||
+ if (_my_tls.sig)
|
||||
+ _my_tls.set_signal_arrived ();
|
||||
|
||||
if (!res)
|
||||
{
|
||||
@@ -785,7 +789,16 @@ 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);
|
||||
+ do
|
||||
+ {
|
||||
+ rc = cygwait (pack.wakeup, WSSC, cw_sig_eintr);
|
||||
+ if (rc == WAIT_SIGNALED && pack.si.si_signo != __SIGFLUSHFAST)
|
||||
+ _my_tls.call_signal_handler ();
|
||||
+ }
|
||||
+ while (rc != WAIT_OBJECT_0 && rc != WAIT_TIMEOUT);
|
||||
+ /* Re-assert signal_arrived which has been cleared in cygwait(). */
|
||||
+ if (_my_tls.sig)
|
||||
+ _my_tls.set_signal_arrived ();
|
||||
ForceCloseHandle (pack.wakeup);
|
||||
}
|
||||
else
|
||||
@@ -806,9 +819,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)
|
||||
{
|
||||
@ -4,7 +4,7 @@
|
||||
pkgbase=msys2-runtime
|
||||
pkgname=('msys2-runtime' 'msys2-runtime-devel')
|
||||
pkgver=3.5.5
|
||||
pkgrel=1
|
||||
pkgrel=2
|
||||
pkgdesc="Cygwin POSIX emulation engine"
|
||||
arch=('x86_64')
|
||||
url="https://www.cygwin.com/"
|
||||
@ -72,7 +72,8 @@ source=('msys2-runtime'::git://sourceware.org/git/newlib-cygwin.git#tag=cygwin-$
|
||||
0041-cygthread-suspend-thread-before-terminating.patch
|
||||
0042-Cygwin-revert-use-of-CancelSyncronousIo-on-wait_thre.patch
|
||||
0043-Cygwin-cache-IsWow64Process2-host-arch-in-wincap.patch
|
||||
0044-Cygwin-uname-add-host-machine-tag-to-sysname.patch)
|
||||
0044-Cygwin-uname-add-host-machine-tag-to-sysname.patch
|
||||
0045-Cygwin-signal-Do-not-handle-signal-when-__SIGFLUSHFA.patch)
|
||||
sha256sums=('0c6fcf91be78369e753deb1963b4a04e0db613194e70a7ec653774b028adf509'
|
||||
'76e37d572d2aba473aab8f5a1984af2084e6069f9195795c71bc45778edbd1eb'
|
||||
'5c79b09f9337cc8a5f993db6dd1f54df269f8390ab3348a94e5a139a5d060e39'
|
||||
@ -117,7 +118,8 @@ sha256sums=('0c6fcf91be78369e753deb1963b4a04e0db613194e70a7ec653774b028adf509'
|
||||
'eac80fb3b54dced1e982c01a755c1914eccd1f8d74b7b88a0af43819ab317a2f'
|
||||
'29c3412a1c7b0e4e719b64337ba5508b141037884ba96e9bee5f8ea253811aa3'
|
||||
'7064362256cb558fe443469b5f9988ca927667b7cf13f1c1020aca98e616f900'
|
||||
'fb6c38381eb4f36338a5184f79c98e6046c9ff741da37f2f38f4757c8714ca92')
|
||||
'fb6c38381eb4f36338a5184f79c98e6046c9ff741da37f2f38f4757c8714ca92'
|
||||
'84bbe9320fe9fdc8bf6af88c9ae68eaff4bc8e162ba58ba7422bbd053e88a986')
|
||||
|
||||
# Helper macros to help make tasks easier #
|
||||
apply_patch_with_msg() {
|
||||
@ -198,7 +200,8 @@ prepare() {
|
||||
0041-cygthread-suspend-thread-before-terminating.patch \
|
||||
0042-Cygwin-revert-use-of-CancelSyncronousIo-on-wait_thre.patch \
|
||||
0043-Cygwin-cache-IsWow64Process2-host-arch-in-wincap.patch \
|
||||
0044-Cygwin-uname-add-host-machine-tag-to-sysname.patch
|
||||
0044-Cygwin-uname-add-host-machine-tag-to-sysname.patch \
|
||||
0045-Cygwin-signal-Do-not-handle-signal-when-__SIGFLUSHFA.patch
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user