public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: sigproc: Fix potential race issue regarding exit_state.
@ 2021-11-19 18:39 Takashi Yano
  2021-11-22 12:45 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Yano @ 2021-11-19 18:39 UTC (permalink / raw)
  To: cygwin-patches

- If sig_send() is called while another thread is processing exit(),
  race issue regarding exit_state may occur. This patch fixes the
  issue.
---
 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);
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Cygwin: sigproc: Fix potential race issue regarding exit_state.
  2021-11-19 18:39 [PATCH] Cygwin: sigproc: Fix potential race issue regarding exit_state Takashi Yano
@ 2021-11-22 12:45 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2021-11-22 12:45 UTC (permalink / raw)
  To: cygwin-patches

On Nov 20 03:39, Takashi Yano wrote:
> - If sig_send() is called while another thread is processing exit(),
>   race issue regarding exit_state may occur. This patch fixes the
>   issue.
> ---
>  winsup/cygwin/sigproc.cc | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

Please push.


Thanks,
Corinna

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-22 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 18:39 [PATCH] Cygwin: sigproc: Fix potential race issue regarding exit_state Takashi Yano
2021-11-22 12:45 ` Corinna Vinschen

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).