From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30863 invoked by alias); 5 Oct 2008 13:41:09 -0000 Received: (qmail 30855 invoked by uid 22791); 5 Oct 2008 13:41:08 -0000 X-Spam-Check-By: sourceware.org Received: from sv2.lisha.ufsc.br (HELO smtp.lisha.ufsc.br) (150.162.62.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 05 Oct 2008 13:40:13 +0000 Received: by smtp.lisha.ufsc.br (Postfix, from userid 99) id 86845BF097; Sun, 5 Oct 2008 10:40:09 -0300 (BRT) Received: from ramiro-pollas-macbook.local (200-233-120-210.sercomtel.com.br [200.233.120.210]) (Authenticated sender: ramiro) by smtp.lisha.ufsc.br (Postfix) with ESMTP id DD622BF02E for ; Sun, 5 Oct 2008 10:40:08 -0300 (BRT) Message-ID: <48E8C3B8.2080709@lisha.ufsc.br> Date: Sun, 05 Oct 2008 13:41:00 -0000 From: Ramiro Polla User-Agent: Thunderbird 2.0.0.17 (Macintosh/20080914) MIME-Version: 1.0 To: pthreads-win32@sourceware.org Subject: Re: pthreads-win32 2.8.0, stack alignment, and SSE code References: <48E8B399.502@yahoo.fr> In-Reply-To: <48E8B399.502@yahoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2008/txt/msg00054.txt.bz2 Sébastien Kunz-Jacques wrote: > Hi, > > I encountered problems with SSE code compiled with recent mingw GCC > (4.3.2, TDM release, http://www.tdragon.net/recentgcc/) and using > pthreads 2.8.0. After inverstigation, crashes occured because the code > was trying to read operands on the stack, assuming the stack was 16-byte > aligned as is the case in the main thread (the main function aligns the > stack and alignment is maintained during each function call). I solved > the issue with a very simple patch that uses some GCC wizardry to force > stack realignment upon entry in a new thread: > > --- ptw32_threadStart.c Sun May 15 17:28:27 2005 > +++ ptw32_threadStart.c Mon Sep 29 21:28:16 2008 > @@ -116,6 +116,9 @@ > > #endif > > +#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && > __GNUC_MINOR__>1) > +__attribute__((force_align_arg_pointer)) > +#endif > #if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined > (__DMC__)) > unsigned > __stdcall > > > The attribute force_align_arg_pointer should be added to every function > that is called with a stack with insufficient alignment; as far as I am > concerned doing this for threadStart only solved my problems. Maybe this > small patch could be added to the pthread code? I think that's related to: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216 So I think this patch shouldn't be applied to pthreads-win32, and people should rather use another version of MinGW (or unset automatic SSE code, if that makes any sense). Ramiro Polla