delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/12/22/10:47:12

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 5BMFlC0o1008258
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 5BMFlC0o1008258
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=AlYyttgU
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 889E94BA2E21
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1766418431;
bh=2f22kXyRRr8zJ2TtgemFpQCHMjZUvpF9Jj9Vcr6Ofvk=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=AlYyttgUEViNtWwIDtHd9GrmzwSyq/FBI/TSnPQV/7KPtmn7R9h7L9wn03VlPUXL3
wOq8LqAC7NfuqwckhVThSEnvEIARUfFsQ5mztxdP3C6Y2wg1y3bI3OrSuOQFpv8zdo
aFaEc3fn430K1Guhr0Px2Sc7Qorx0TK57xLIkrZI=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 267864BA2E06
Date: Mon, 22 Dec 2025 16:46:53 +0100
To: cygwin AT cygwin DOT com
Subject: Re: Recent testsuite/winsup.api/pthread/cancel2 failure
Message-ID: <aUln7b98tXZ6juG8@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
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>
<20251222233746 DOT d45ae16e4e06de5af7b27f26 AT nifty DOT ne DOT jp>
MIME-Version: 1.0
In-Reply-To: <20251222233746.d45ae16e4e06de5af7b27f26@nifty.ne.jp>
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: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
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 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.

But afaic the stack is always 8 byte aligned anyway.  However, there are
some scenarios where 16 byte alignment is required, as for context
itself when calling RtlCaptureContext.  Maybe that's the problem here?

But the context Stackptr is the stackpointer of the current function the
target thread is running in.  The instruction pointer is set to
pthread::static_cancel_self(), which doesn't get any arguments and doesn't
use any content from the stack.

It might be a good idea to make sure the stack is always 16 byte
aligned, but I don't see why pthread::static_cancel_self() ->
pthread::cancel_self() -> pthread::exit() would require other than 8
byte alignment.

Apparently something in pthread::exit() crashes?  But where?  Does
adding debug_printf's help to figure that out?


Corinna

-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019