Recent testsuite/winsup.api/pthread/cancel2 failure
Takashi Yano
takashi.yano@nifty.ne.jp
Tue Dec 23 12:17:25 GMT 2025
On Tue, 23 Dec 2025 19:07:13 +0900
Takashi Yano wrote:
> On Mon, 22 Dec 2025 16:46:53 +0100
> Corinna Vinschen wrote:
> > On Dec 22 23:37, Takashi Yano via Cygwin wrote:
> > > 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;
> >
> > Does that really help? Checking for 8 byte alignment is usually done
> > with (X & 7) != 0, because this won't catch 16 byte aligned stacks.
>
> This code does not aim for 8 byte alignment, but 16n + 8. I assume
> context._CX_stackPtr & 7 is always 0. I wonder if this assumption
> is true. What if user code pushes 16 bit register such as AX?
> It might be necessary to mask least 3 bits in advance.
>
> diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
> index 86a00e76e..628aef16f 100644
> --- a/winsup/cygwin/thread.cc
> +++ b/winsup/cygwin/thread.cc
> @@ -630,6 +630,9 @@ pthread::cancel ()
> threadlist_t *tl_entry = cygheap->find_tls (cygtls);
> if (!cygtls->inside_kernel (&context))
> {
> + context._CX_stackPtr &= 0xfffffffffffffff8UL;
> + if ((context._CX_stackPtr & 8) == 0)
> + context._CX_stackPtr -= 8;
> context._CX_instPtr = (ULONG_PTR) pthread::static_cancel_self;
> SetThreadContext (win32_obj_id, &context);
> }
I confirmed that the attached reproducer (repro.c) works fine with
this patch.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repro.c
Type: text/x-csrc
Size: 995 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20251223/fa5fa797/attachment.bin>
More information about the Cygwin
mailing list