From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 24 07:36:58 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8810A16A4CE; Wed, 24 Nov 2004 07:36:58 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id E7EFF43D69; Wed, 24 Nov 2004 07:36:57 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) iAO7auZE009146; Wed, 24 Nov 2004 02:36:56 -0500 (EST) Date: Wed, 24 Nov 2004 02:36:55 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Craig Boston In-Reply-To: <200411240102.42269.craig@tobuj.gank.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-hackers@freebsd.org cc: freebsd-threads@freebsd.org Subject: Re: SSE vs. stack alignment vs. pthread X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2004 07:36:58 -0000 On Wed, 24 Nov 2004, Craig Boston wrote: > First of all, I'd like to apologize for cross-posting to -hackers and > -threads. I'm not sure yet if this is an application bug, a gcc > bug, or a pthreads bug, so here goes... > > I'm currently working on the audacity port. It's up to 1.2.3, but I > want to get a problem I've observed with 1.2.2 resolved to make sure > that it doesn't crop up later or affect other software... > > Long story short, audacity is a threaded program. A straight compile of > 1.2.2 results in a 100% reproducible bus error that happens on multiple > Pentium-4 machines (5.3-STABLE). It always happens at this instruction: > > 0x081807c4: movaps %xmm0,0xffffff68(%ebp) > > Now, at that time ebp is 0xbfadc6c0, so ebp+0xffffff68 (-0x152) is 0xbfadc56e. > Oops, that's not 16-byte aligned like SSE wants. The offsets vary sligthly > depending on the compile flags, etc., but the result is always the same -- > SIGBUS. Tor Egge reported similar problem to me yesterday. I haven't had a chance to test his patch, but this supposedly fixes it. Index: lib/libc/i386/gen/makecontext.c =================================================================== RCS file: /home/ncvs/src/lib/libc/i386/gen/makecontext.c,v retrieving revision 1.4 diff -u -r1.4 makecontext.c --- lib/libc/i386/gen/makecontext.c 2 Jul 2004 14:19:44 -0000 1.4 +++ lib/libc/i386/gen/makecontext.c 22 Nov 2004 22:51:49 -0000 @@ -118,7 +118,9 @@ * address, _ctx_start, and ucp) and argc arguments. * We allow the arguments to be pointers also. */ - stack_top = stack_top - (sizeof(intptr_t) * (3 + argc)); + stack_top = stack_top - (sizeof(intptr_t) * (1 + argc)); + stack_top -= ((long) stack_top & 15); /* 16 bytes alignment */ + stack_top -= sizeof(intptr_t) * 2; argp = (intptr_t *)stack_top; /*