This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: 16 byte pthread stack alignments
On Wed, 21 Dec 2011, Corinna Vinschen wrote:
> 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?!?
It appears it is, here.
> Does anybody care to tell me what's wrong with the assembler code in
> thread_wrapper?
I don't pretend to understand why, but it appears gcc is expecting the
stack to be 16 byte aligned on entry to the called function, which
includes the 4 byte argument and the 4 byte return address in this case.
I could be wrong, but it appears that would do it.
For a long discussion by those who apparently agree with you about how
crazy this is see:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838
It looks like gcc 4.6 may finally "do the right thing" itself.
--
Brian Ford
Staff Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained crew...
--
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