From owner-freebsd-current@FreeBSD.ORG Wed Jul 4 21:14:20 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 77659106566C; Wed, 4 Jul 2012 21:14:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id E2DC78FC17; Wed, 4 Jul 2012 21:14:19 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q64LER3A045777; Thu, 5 Jul 2012 00:14:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q64LEFZ2016307; Thu, 5 Jul 2012 00:14:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q64LEEQ7016306; Thu, 5 Jul 2012 00:14:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 5 Jul 2012 00:14:14 +0300 From: Konstantin Belousov To: Taku YAMAMOTO Message-ID: <20120704211414.GR2337@deviant.kiev.zoral.com.ua> References: <20120704233316.70ec8654.taku@tackymt.homeip.net> <4FF45C6E.1080000@FreeBSD.org> <20120705003201.bb297e8a.taku@tackymt.homeip.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="udoRqEMdU50CdIRN" Content-Disposition: inline In-Reply-To: <20120705003201.bb297e8a.taku@tackymt.homeip.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-current@freebsd.org, Dimitry Andric 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: Wed, 04 Jul 2012 21:14:20 -0000 --udoRqEMdU50CdIRN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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: >=20 > > On 2012-07-04 16:33, Taku YAMAMOTO wrote: > > > For people having SIGBUS with clang-build world + gcc-build binaries, > > >=20 > > >=20 > > > 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=3D8! > > >=20 > > > The detail is as follows. > > >=20 > > > I've observed that clang carelessly expects the stack being aligned at > > > 16 byte boundary. > >=20 > > 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). >=20 > Oops, I had to be clear about that! > Yes, the experiment was took on i386 (actually -march=3Dpentium4). >=20 > > Note that you would get the same issue with newer versions of gcc, which > > will also assume this alignment. >=20 > 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. i386 csu explicitely aligns the stack before calling into C land, everything else should be the C compiler own offence :). --udoRqEMdU50CdIRN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/0siUACgkQC3+MBN1Mb4g32QCff5GaW0Rvk4uuUiNlh++/kj6Y oD0An2u8FqC6zVpCdMHi/gwE069pgNGj =Q70s -----END PGP SIGNATURE----- --udoRqEMdU50CdIRN--