[PATCH] Cygwin: sigtimedwait: Fix segfault when timeout is used

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Nov 18 15:34:55 GMT 2024


Hi Takashi,

thanks for looking into this problem.

On Nov 18 00:48, Takashi Yano wrote:
> @@ -640,6 +641,16 @@ sigwait_common (const sigset_t *set, siginfo_t *info, PLARGE_INTEGER waittime)
>  	    }
>  	  break;
>  	case WAIT_TIMEOUT:
> +	  _my_tls.lock ();
> +	  if (_my_tls.sigwait_mask == 0)
> +	    {
> +	      /* sigpacket::process() already started. */
> +	      waittime = cw_infinite;

cw_infinite?  Shouldn't this situation lead to cygwait returning
immediately with WAIT_SIGNALLED?  The theory would explain to me
that the timeout doesn't matter in this case, but given that the
actual, configured timeout already occured, wouldn't it be
safer to set timeout to 0?  Just in case?

> +	      _my_tls.unlock ();
> +	      goto do_wait;
> +	    }
> +	  _my_tls.sigwait_mask = 0;
> +	  _my_tls.unlock ();
>  	  set_errno (EAGAIN);
>  	  break;
>  	default:

Thanks,
Corinna



More information about the Cygwin-patches mailing list