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: g++ 3.4.0 cygwin, codegen SSE & alignement issues


On Wed, 28 Apr 2004, tbp wrote:

> Building an app of mine (multithreaded) with something like -O3
> -march=k8 the binary died with an illegal instruction. The offending
> instruction was a 'movaps %xmm0, 0x40(%esp)' with an unaligned esp.
> As that was on a secondary thread after some external calls (opengl and
> so on) i thought it had to do with some cygwin/ABI issue or something.
>
> After a day of struggling/web digging, i still had no clue.
[snip]
> I'm puzzled & surprised that nobody tripped that one earlier and i'd
> apreciate any clue.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14776

I'm working with Red Hat to resolve this issue right now.  The problem is
that thread stacks are not always 16 byte aligned.  You could try the
following hack if you need something right away and don't mind building
your own Cygwin DLL.

2004-04-28  DJ Delorie  <dj@redhat.com>

        * init.cc (threadfunc_fe): Hack to make thread stacks always 16
	byte aligned.

Index: init.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/init.cc,v
retrieving revision 1.32
diff -u -p -r1.32 init.cc
--- init.cc     22 Mar 2004 18:30:38 -0000      1.32
+++ init.cc     28 Apr 2004 17:38:03 -0000
@@ -27,6 +27,8 @@ HANDLE sync_startup;
 static void WINAPI
 threadfunc_fe (VOID *arg)
 {
+  (void)__builtin_return_address(1);
+  asm volatile ("andl $-16,%%esp" ::: "%esp");
   _cygtls::call ((DWORD (*)  (void *, void *)) (((char **)
_tlsbase)[OLDFUNC_OFFSET]), arg);
 }

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

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


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