Re: Recent testsuite/winsup.api/pthread/cancel2 failure

Takashi Yano via Cygwin <[email protected]>
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
On Sun, 14 Dec 2025 16:26:37 +0900
Takashi Yano via Cygwin <[email protected]> wrote:

> Recently, I have concerned that testsuite winsup.api/pthread/cancel2 fails
> consistently.
> 
> https://github.com/cygwin/cygwin/actions/runs/19926408142/job/57127200619
> 
> I'm not sure why this happens, but it also falis in my local environment.
> I looked into this issue a bit, and found that access violation happnes
> in CloseHandle() in _cygtls::remove().
> 
> And I am also not sure why at all, cancel2 works if CloseHandle()'s are
> replaced with NtClose() as follows.
> 
> diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
> index 13d133f47..249c8cb18 100644
> --- a/winsup/cygwin/cygtls.cc
> +++ b/winsup/cygwin/cygtls.cc
> @@ -118,7 +118,7 @@ _cygtls::remove (DWORD wait)
>      {
>        HANDLE h = signal_arrived;
>        signal_arrived = NULL;
> -      CloseHandle (h);
> +      NtClose (h);
>      }
>  
>    if (locals.drivemappings)
> @@ -148,7 +148,7 @@ _cygtls::remove (DWORD wait)
>    if (mutex)
>      {
>        ReleaseMutex (mutex);
> -      CloseHandle (mutex);
> +      NtClose (mutex);
>      }
>  }
>  
> 
> Any idea?

I forgot to mention that the thread crashes when canceled with
PTHREAD_CANCEL_ASYNCHRONOUS.

PTHREAD_CANCEL_DEFERRED works without the problem.

-- 
Takashi Yano <[email protected]>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.