On Sat, 31 May 2025 10:16:22 +0900
Takashi Yano wrote:
> Currently, _cygtls::sigmask is set in call_signal_handler(), but this
> is too late to effectively prevent a masked signal from being armed. 
> With this patch, sigmask is set in _cygtls::interrupt_setup() instead.
> 
> Fixes: 0d675c5d7f24 ("* exceptions.cc (interrupt_setup): Don't set signal 
> mask here or races occur with main thread.  Set it in sigdelayed instead.")
> Reviewed-by:
> Signed-off-by: Takashi Yano <[email protected]>
> ---
>  winsup/cygwin/exceptions.cc | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
> index bcc7fe6f8..688297d76 100644
> --- a/winsup/cygwin/exceptions.cc
> +++ b/winsup/cygwin/exceptions.cc
> @@ -980,7 +980,8 @@ void
>  _cygtls::interrupt_setup (siginfo_t& si, void *handler, struct sigaction& 
> siga)
>  {
>    push ((__tlsstack_t) sigdelayed);
> -  deltamask = siga.sa_mask & ~SIG_NONMASKABLE;
> +  oldmask = sigmask;
> +  sigmask = (sigmask | siga.sa_mask) & ~SIG_NONMASKABLE;
>    sa_flags = siga.sa_flags;
>    func = (void (*) (int, siginfo_t *, void *)) handler;
>    if (siga.sa_flags & SA_RESETHAND)
> @@ -1721,7 +1722,7 @@ _cygtls::call_signal_handler ()
>        debug_only_printf ("dealing with signal %d", current_sig);
>        this_sa_flags = sa_flags;
>  
> -      sigset_t this_oldmask = set_process_mask_delta ();
> +      sigset_t this_oldmask = _my_tls.oldmask;
>  
>        if (infodata.si_code == SI_TIMER)
>       {
> -- 
> 2.45.1

I'd withdraw this patch because this patch seems to cause a race
issue as mensioned in the commit message of the commit 0d675c5d7f24.

Instead, I would like to propose another patch for the sema purpose.
https://cygwin.com/pipermail/cygwin-patches/2025q2/013749.html

-- 
Takashi Yano <[email protected]>

Reply via email to