public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: sigproc: Fix potential race issue regarding exit_state. Date: Mon, 22 Nov 2021 14:26:43 +0000 (GMT) [thread overview] Message-ID: <20211122142643.102D83858D35@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5bef105680aa87ad5832d679e9cd74022574968d commit 5bef105680aa87ad5832d679e9cd74022574968d Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Sat Nov 20 03:24:18 2021 +0900 Cygwin: sigproc: Fix potential race issue regarding exit_state. - If sig_send() is called while another thread is processing exit(), race issue regarding exit_state may occur. This patch fixes the issue. Diff: --- winsup/cygwin/sigproc.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index fde41a9f6..02d875a7f 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -603,11 +603,6 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) its_me = false; } - /* Do not send signal to myself if exiting, which will be - ignored in wait_sig thread. */ - if (its_me && exit_state > ES_EXIT_STARTING && si.si_signo > 0) - goto out; - if (its_me) sendsig = my_sendsig; else @@ -1372,7 +1367,7 @@ wait_sig (VOID *) sigq.retry = false; /* Don't process signals when we start exiting */ if (exit_state > ES_EXIT_STARTING && pack.si.si_signo > 0) - continue; + goto skip_process_signal; sigset_t dummy_mask; threadlist_t *tl_entry; @@ -1384,8 +1379,10 @@ wait_sig (VOID *) pack.mask = &dummy_mask; } - sigpacket *q = &sigq.start; - bool clearwait = false; + sigpacket *q; + q = &sigq.start; + bool clearwait; + clearwait = false; switch (pack.si.si_signo) { case __SIGCOMMUNE: @@ -1482,6 +1479,7 @@ wait_sig (VOID *) } if (clearwait && !have_execed) proc_subproc (PROC_CLEARWAIT, 0); +skip_process_signal: if (pack.wakeup) { sigproc_printf ("signalling pack.wakeup %p", pack.wakeup);
reply other threads:[~2021-11-22 14:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211122142643.102D83858D35@sourceware.org \ --to=tyan0@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).