Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Wed, 28 Apr 2004 12:41:51 -0500 From: Brian Ford Reply-To: cygwin AT cygwin DOT com To: tbp cc: cygwin AT cygwin DOT com Subject: Re: g++ 3.4.0 cygwin, codegen SSE & alignement issues In-Reply-To: <408F2C65.4090804@ompf.org> Message-ID: References: <408F2C65 DOT 4090804 AT ompf DOT org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes 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 * 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/