delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/12/21/11:51:49

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 21 Dec 2011 17:50:53 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: 16 byte pthread stack alignments
Message-ID: <20111221165053.GA9699@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <Pine DOT CYG DOT 4 DOT 58 DOT 1112201743030 DOT 3964 AT PC1163-8460-XP DOT flightsafety DOT com> <20111221094211 DOT GH23547 AT calimero DOT vinschen DOT de> <4EF1F937 DOT 9040107 AT gmail DOT com> <20111221154104 DOT GB11841 AT calimero DOT vinschen DOT de> <Pine DOT CYG DOT 4 DOT 58 DOT 1112211020000 DOT 3076 AT PC1163-8460-XP DOT flightsafety DOT com>
MIME-Version: 1.0
In-Reply-To: <Pine.CYG.4.58.1112211020000.3076@PC1163-8460-XP.flightsafety.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Dec 21 10:22, Brian Ford wrote:
> On Wed, 21 Dec 2011, Corinna Vinschen wrote:
> 
> > On Dec 21 15:20, Dave Korn wrote:
> > >   GCC assumes that the stack starts off 16-aligned when the OS hands over to
> > > the exe's entrypoint, and then makes sure it stays that way by always rounding
> > > stack frame sizes up to the nearest multiple of 16.  Or at any rate that's how
> > > it's supposed to work.
> >
> > Ok.  Does that mean my patch from
> > http://cygwin.com/ml/cygwin/2011-12/msg00435.html should be the right
> > thing to do for pthreads?  I guess I will have to do the same in
> > _dll_crt0 then...
> 
> Probably.  I'm trying to test now, but I haven't built cygwin in years now
> so I'm still working to get things set up.  I've also lost track of Cygwin
> internals.  Does it make sense to you that those two patches from 2004
> would no longer be effective?

Cygwin now sets up the stack by itself in both cases, WOW64 startup and
pthread_create.  I just made a test which showed pretty clearly that
the 16 byte alignment is required for the WOW64 case.  But that case
wasn't affected because it was already correctly aligned.

On second thought I'm a bit puzzled that the pthread stack isn't
correctly aligned as well.  Ignoring the pthread_attr_setstack case
which wasn't supported so far anyway, the OS stack set up by
CreateThread is 64K aligned.  From that 64K aligned StackBase value, I
subtract 12704 == 0x31a0 bytes.  So the result should be 16 byte
aligned even without the andl $-16, %%esp.  Why isn't it?!?
Does anybody care to tell me what's wrong with the assembler code in
thread_wrapper?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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