This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 16 byte pthread stack alignments


On Dec 20 17:45, Brian Ford wrote:
> I'm just headed home from work right now, but I thought I would let you
> know of a regression from 1.7.9.  It appears the effect of this patch:
> 
> http://www.cygwin.com/ml/cygwin-cvs/2004-q2/msg00124.html
> 
> is no longer working in the current snapshot.  I'll try to narrow it down
> to which change caused the regression and send in an STC tomorrow.

Is that the first Cygwin process started from a 64 bit process on 64 bit
XP or 2003?  If so, see the new wow64_revert_to_original_stack function
in wow64.cc and the wow64 code in _dll_crt0.

I don't see how any other change could have this effect.  But I also
don't see how this could occur with the patch.  Basically, what happens
is this:

  newbase = some 64K aligned address on the stack
  _main_tls = newbase - CYGTLS_PADSIZE (== 12700)
  $ebp = $esp = _main_tls - 4

So, assuming newbase == 0x10000
    ==> _main_tls == 0xce64
    ==> $ebp/$esp == 0xce60, which is certainly a 16 byte aligned value.

But OTOH I have to admit that I don't see how this alignment business
worked at all.  Aligning the stack to 16 byte in mainCRTStartup doesn't
guarantee that the stack is still 16 byte aligned in main().  If that
worked so far, it seems like a miracle.  The call stack looks like this:

  mainCRTStartup
  -> cygwin_crt0
     -> _dll_crt0
        -> _main_tls->call
	   -> _main_tls->call2
	      -> dll_crt0_1
	         -> main

Every function on the stack changes the stack pointer.  How did that
work?  Coincidence?

And then again, isn't it gcc's job to make sure that the generated code
makes sure the stack is correctly aligned for certain opcodes?

What am I missing?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]