| delorie.com/archives/browse.cgi | search |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 delorie.com 5BMEceMW817921 |
| Authentication-Results: | delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com |
| Authentication-Results: | delorie.com; spf=pass smtp.mailfrom=cygwin.com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 delorie.com 5BMEceMW817921 |
| Authentication-Results: | delorie.com; |
| dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=kvEsGnGQ | |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org EEB704BA2E32 |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
| s=default; t=1766414320; | |
| bh=9ePQQ+ZaTtYFq22W31ytROft0Qc/QyY6v4r/BT8Unho=; | |
| h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: | |
| List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: | |
| From; | |
| b=kvEsGnGQQHGGi7aZ5ho7tGl5RE2Fa2gNZCx0+ahQwc/Ge0eUrCa2lnMMTmONg+yN3 | |
| bXJogwpTkv5NysoUVfh8TBzTcDnE/k4A+aHT35HfwGOBNlHrOpYQVA1CF/uqdzfIdD | |
| +d99P+SttcL9Pm30L22e33lo6l3W7uAyKECJnaqI= | |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 sourceware.org 998CC4BA2E04 |
| ARC-Filter: | OpenARC Filter v1.0.0 sourceware.org 998CC4BA2E04 |
| ARC-Seal: | i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1766414268; cv=none; |
| b=nv4DLfev3Dn/E/PE0TL7Ups9HOezrr9ORfj4X/mniTabWciGQppdUusR+IVuFC1xvZKUrZggmB3SepZys7cbn30wymfPVrjp1Fep41+T+YPwLEptWNJp8sjgnGJFqr+E21qxlSQnlIIHKrTJvXPIR9RS8IAnMnjGbLtzytu3DdM= | |
| ARC-Message-Signature: | i=1; a=rsa-sha256; d=sourceware.org; s=key; |
| t=1766414268; c=relaxed/simple; | |
| bh=wIeKa935Rh3IEDBosCu+2C4oBLvL6jn6tI7oA09Vbe4=; | |
| h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature; | |
| b=a438V14wFvta/B1XiZpJ4hweaz8fNcLPLh0WMkSE4JAn+RYLHW/1O9tzpYWdC5+sTlO7WnP+2GvDqHG6mXJC13vV59dwwWBTy3EF7tMqFIGFdib4HHn6GfaCf0ri9e9FGJzky9Od/6eGP7AXAz8pj2Yz1JOIOM7Ye7DAXwdamus= | |
| ARC-Authentication-Results: | i=1; server2.sourceware.org |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 998CC4BA2E04 |
| Date: | Mon, 22 Dec 2025 23:37:46 +0900 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: Recent testsuite/winsup.api/pthread/cancel2 failure |
| Message-Id: | <20251222233746.d45ae16e4e06de5af7b27f26@nifty.ne.jp> |
| In-Reply-To: | <20251222230450.a2e308861cebfab9cdb5dcc1@nifty.ne.jp> |
| References: | <20251214162637 DOT 1ee05b084788ba073fe94670 AT nifty DOT ne DOT jp> |
| <20251214163936 DOT 6841fc62145d8f54cfa31fe7 AT nifty DOT ne DOT jp> | |
| <9d058204-fb3f-43b4-9e32-6adc7af12ff4 AT dronecode DOT org DOT uk> | |
| <20251217193737 DOT 3d3d686ebe3865c183315dc5 AT nifty DOT ne DOT jp> | |
| <20251222230450 DOT a2e308861cebfab9cdb5dcc1 AT nifty DOT ne DOT jp> | |
| X-Mailer: | Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) |
| Mime-Version: | 1.0 |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.30 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe> | |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| From: | Takashi Yano via Cygwin <cygwin AT cygwin DOT com> |
| Reply-To: | Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp> |
| Errors-To: | cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com |
| Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
On Mon, 22 Dec 2025 23:04:50 +0900
Takashi Yano wrote:
> On Wed, 17 Dec 2025 19:37:37 +0900
> Takashi Yano wrote:
> > Hi Jon,
> >
> > Thanks for the reply.
> >
> > On Tue, 16 Dec 2025 13:11:15 +0000
> > Jon Turney wrote:
> > > On 14/12/2025 07:39, Takashi Yano via Cygwin wrote:
> > > > On Sun, 14 Dec 2025 16:26:37 +0900
> > > > Takashi Yano via Cygwin <cygwin AT cygwin DOT com> wrote:
> > > >
> > > >> Recently, I have concerned that testsuite winsup.api/pthread/cancel2 fails
> > > >> consistently.
> > > >>
> > > >> https://github.com/cygwin/cygwin/actions/runs/19926408142/job/57127200619
> > >
> > > Thanks very much for looking into this!
> > >
> > > I have the vague idea that this problem started showing up (more?) when
> > > the CI VM was upgraded from Windows Server 2022 to Windows Server 2025,
> > > but I guess that's maybe just timings...
> >
> > IIRC, this did not happen when I uses Win10. Now, I'm using Win11.
> >
> > > >> 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.
> > >
> > > I think this is just the difference between the two calls: CloseHandle
> > > generates an exception whereas NtClose returns an error code if the
> > > handle is invalid.
> > >
> > > Doesn't really explain whats wrong with the handle, though.
> >
> > I checked the return code of NtClose() and found the it is STATUS_SUCCESS.
> > If the handle is invalid, NtClose() returns error code, I think...
>
> I worked on this issue, and found the following code solves the issue,
> without "CloseHandle()/NtClose()" patch.
>
> diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
> index 86a00e76e..82d52f44f 100644
> --- a/winsup/cygwin/thread.cc
> +++ b/winsup/cygwin/thread.cc
> @@ -630,6 +630,8 @@ pthread::cancel ()
> threadlist_t *tl_entry = cygheap->find_tls (cygtls);
> if (!cygtls->inside_kernel (&context))
> {
> + *(ULONG_PTR *) context._CX_stackPtr = context._CX_instPtr;
> + context._CX_stackPtr -= sizeof (ULONG_PTR);
> context._CX_instPtr = (ULONG_PTR) pthread::static_cancel_self;
> SetThreadContext (win32_obj_id, &context);
> }
>
> But, I'm not sure why at all.
>
> pthread::static_cancel_self() never returns, so stack should not affect,
> I think.
>
> Any idea?
Alignment issue?
This might be the right thing.
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 86a00e76e..ec1e3c98c 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -630,6 +630,8 @@ pthread::cancel ()
threadlist_t *tl_entry = cygheap->find_tls (cygtls);
if (!cygtls->inside_kernel (&context))
{
+ if ((context._CX_stackPtr & 8) == 0)
+ context._CX_stackPtr -= 8;
context._CX_instPtr = (ULONG_PTR) pthread::static_cancel_self;
SetThreadContext (win32_obj_id, &context);
}
--
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |