Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Oct 2012 00:10:12 +0200
From:      Tijl Coosemans <tijl@coosemans.org>
To:        Shane Ambler <FreeBSD@ShaneWare.Biz>
Cc:        gerald@freebsd.org, FreeBSD-ports <freebsd-ports@freebsd.org>
Subject:   Re: Possible regression in i386 build with gcc 4.6
Message-ID:  <5071FDC4.4060603@coosemans.org>
In-Reply-To: <506B3E9A.1000905@ShaneWare.Biz>
References:  <506B3E9A.1000905@ShaneWare.Biz>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig039F7288FF3236BBE4723773
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 02-10-2012 21:20, Shane Ambler wrote:
> I found a situation where gcc v4.2 compiles a i386 working binary and
> v4.6 doesn't. (Currently 4.7 and 4.8 fail to build this code) I have
> verified that this happens with 8.2/8.3/9.0 i386 systems. x86_64
> versions build without issue as does clang i386/x86_64.
>=20
> It appears that the x86_64 target of gcc offers gcc atomics while the
> i386 target doesn't - and this appears to be a freebsd specific setup,
> the i386 targets then fall back to using tbb atomics.
>=20
> Is this some subtle bug I'm missing? can it be alleviated with compiler=

> flags/more universal code?
>=20
> I have tried to cut this down to just the call that triggers a
> segmentation fault but the one call itself isn't enough.
>=20
> The issue can be found in graphics/openimageio. The easiest way I know
> to cause the segmentation fault is with the image viewer that is part o=
f
> the port (it is a Qt app) it seg faults during startup. There is no nee=
d
> to open any images just starting iv with an empty window is fine.
>=20
> The makefile is setup to USE_GCC=3D4.6+ for i386/8.2 - this is a leftov=
er
> from earlier versions that will be removed next update.
>=20
> cd /usr/ports/graphics/openimageio
> make
> ./work/.build/iv/iv
>=20
> The error appears to stem from line 193 of src/libutil/ustring.cpp
>=20
> atomic_exchange_and_add (&ustring_stats_constructed, 1);
>=20
> Commenting this line prevents the crash but isn't a valid fix.
> the relevant function it calls is -- src/include/thread.h:283
> which uses the atomic class template from tbb for the i386 build.
>=20
> inline long long
> atomic_exchange_and_add (volatile long long *at, long long x)
> {
> #ifdef USE_GCC_ATOMICS
>     return __sync_fetch_and_add (at, x);
> #elif USE_TBB
>     atomic<long long> *a =3D (atomic<long long> *)at;

This cast is dangerous. It looks like atomic<long long> has 8 byte
alignment, but long long on i386 only has 4 byte alignment.

>     return a->fetch_and_add (x);
> #elif defined(__APPLE__)
>   <snip>
> #endif
> }




--------------enig039F7288FF3236BBE4723773
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iF4EAREIAAYFAlBx/ckACgkQfoCS2CCgtitj2gD7BZW/3eQarzMz4/Orxt8IeWfA
6gMOFhx6v9DYEse9bYUA/3mjWmGL8XPES4GqCxCD05Q+0R7mxnqml7ZtXOfBDkxo
=gLn7
-----END PGP SIGNATURE-----

--------------enig039F7288FF3236BBE4723773--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5071FDC4.4060603>