From owner-freebsd-current@FreeBSD.ORG Thu Jul 5 20:44:38 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9E0EC106564A for ; Thu, 5 Jul 2012 20:44:38 +0000 (UTC) (envelope-from taku@tackymt.homeip.net) Received: from basalt.tackymt.homeip.net (unknown [IPv6:2001:3e0:577:0:20d:61ff:fecc:2253]) by mx1.freebsd.org (Postfix) with ESMTP id 3C2A98FC0A for ; Thu, 5 Jul 2012 20:44:38 +0000 (UTC) Received: from basalt.tackymt.homeip.net (localhost [127.0.0.1]) by basalt.tackymt.homeip.net (Postfix) with ESMTP id 249BB83A0; Fri, 6 Jul 2012 05:44:37 +0900 (JST) X-Virus-Scanned: amavisd-new at tackymt.homeip.net Received: from localhost by basalt.tackymt.homeip.net (amavisd-new, unix socket) with ESMTP id RBO3pAt9C2Na; Fri, 6 Jul 2012 05:44:35 +0900 (JST) Received: from basalt.tackymt.homeip.net (basalt.tackymt.homeip.net [IPv6:2001:3e0:577:0:20d:61ff:fecc:2253]) by basalt.tackymt.homeip.net (Postfix) with ESMTPSA; Fri, 6 Jul 2012 05:44:35 +0900 (JST) Date: Fri, 6 Jul 2012 05:44:35 +0900 From: Taku YAMAMOTO To: Konstantin Belousov Message-Id: <20120706054435.f23fb592.taku@tackymt.homeip.net> In-Reply-To: <20120705201131.GC2338@deviant.kiev.zoral.com.ua> References: <20120704233316.70ec8654.taku@tackymt.homeip.net> <4FF45C6E.1080000@FreeBSD.org> <20120705003201.bb297e8a.taku@tackymt.homeip.net> <20120704211414.GR2337@deviant.kiev.zoral.com.ua> <20120706041518.de7e2ab5.taku@tackymt.homeip.net> <20120705201131.GC2338@deviant.kiev.zoral.com.ua> X-Mailer: Sylpheed 3.0.3 (GTK+ 2.24.6; i386-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: FYI: SIGBUS with world built by clang X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2012 20:44:38 -0000 On Thu, 5 Jul 2012 23:11:31 +0300 Konstantin Belousov wrote: > On Fri, Jul 06, 2012 at 04:15:18AM +0900, Taku YAMAMOTO wrote: > > On Thu, 5 Jul 2012 00:14:14 +0300 > > Konstantin Belousov wrote: > > > > > On Thu, Jul 05, 2012 at 12:32:01AM +0900, Taku YAMAMOTO wrote: > > > > On Wed, 04 Jul 2012 17:08:30 +0200 > > > > Dimitry Andric wrote: > > > > > > > > > On 2012-07-04 16:33, Taku YAMAMOTO wrote: > > > > > > For people having SIGBUS with clang-build world + gcc-build binaries, > > > > > > > > > > > > > > > > > > In short words, for any libraries (and never forget about rtld-elf!) > > > > > > which are potentially called from arbitrary binaries, > > > > > > compile them with either -mstackrealign or -mstack-alignment=8! > > > > > > > > > > > > The detail is as follows. > > > > > > > > > > > > I've observed that clang carelessly expects the stack being aligned at > > > > > > 16 byte boundary. > > > > > > > > > > Eh, this is a requirement of the amd64 ABI. Any compiler that *doesn't* > > > > > align the stack on 16-byte boundaries is basically broken. Or are you > > > > > experiencing this on i386? Even there, 16-byte alignment would be much > > > > > better in combination with SSE instructions (which arent' enabled by > > > > > default, btw). > > > > > > > > Oops, I had to be clear about that! > > > > Yes, the experiment was took on i386 (actually -march=pentium4). > > > > > > > > > Note that you would get the same issue with newer versions of gcc, which > > > > > will also assume this alignment. > > > > > > > > Interesting, but the base gcc we currently have won't on i386, I think. > > > > (I occationally get bitten by similar problem when using -ftree-vectorize) > > > As far as I understand the rules, $esp % 16 must be zero before call > > > instruction is executed. > > > > I googled and found that it is enforced by MacOS X ABI for IA32 but > > i386 SysV ABI defines otherwise (8 bytes instead of 16 bytes). > No, SysV ABI only requires 4-byte alignment for the stack on i386. (snip) Oh, I stand corrected. Thank you :) -- -|-__ YAMAMOTO, Taku | __ < - A chicken is an egg's way of producing more eggs. -