Bug 791365

Summary: clang segfaults on 64-bit build, works on 32-bit
Product: [Fedora] Fedora Reporter: Matthew Garrett <mjg>
Component: llvmAssignee: Michel Lind <michel>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: bos, dmalcolm, jakub, jfeeney, kalevlember, michel, the.ridikulus.rat
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: llvm-3.0-10.fc17 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-12 03:21:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Matthew Garrett 2012-02-16 20:35:39 UTC
Trying to build an updated hfsplus-tools - the 64-bit build results in http://koji.fedoraproject.org/koji/getfile?taskID=3797349&name=build.log which looks like it's probably not my fault. The 32-bit build seems fine. src.rpm is at http://cavan.codon.org.uk/~mjg59/tmp/hfsplus-tools-540.1.linux3-1.fc17.src.rpm .

Comment 1 Matthew Garrett 2012-02-28 17:04:20 UTC
Suspect this is http://llvm.org/bugs/show_bug.cgi?id=11926

Comment 2 Kalev Lember 2012-03-26 12:04:38 UTC
I poked a bit at llvm/clang and rebuilding it with -O0 instead of -O2 fixed it for me. Certainly sounds very similar to the llvm bug linked in comment #1.

Going to see if I can nail it down to a single optimization flag, instead of just turning everything off.

Comment 3 Kalev Lember 2012-03-26 16:52:28 UTC
I managed to track it down to -ftree-pre that is enabled with -O2. When clang is built with gcc 4.7 using explicit "-O2 -fno-tree-pre", the build works fine on x86_64. Without it, clang segfaults building pretty much anything.

I suspect this might be a gcc 4.7 optimization bug; apparently clang in Fedora isn't fully bootstrapped and is built using gcc. Adding Jakub Jelinek to CC for opinions.

Comment 4 Jakub Jelinek 2012-03-26 17:06:32 UTC
If -O2 -fno-tree-pre works and -O2 doesn't, first narrow it down using a binary
search between -O2 -fno-tree-pre and -O2 compiled objects to at least a single compilation unit, then you could use __attribute__((optimize (1))) (resp.
__attribute__((optimize (2))) ) and/or -fno-inline to narrow it even
further, read the problematic code, see if there aren't any e.g. aliasing
warnings (-O2 enables -fstrict-aliasing), if you don't spot a bug in the
gforth code after this and still suspect the compiler, turn that into
self-contained minimal testcase (for the problematic routine add main
that calls it with the right arguments, make the problematic
routine __attribute__((noinline, noclone)) and stub out anything it calls,
then file a gcc bugreport?

Comment 5 Kalev Lember 2012-03-26 17:25:26 UTC
Thanks Jakub for the pointers. This will make it much easier to track down.

Regarding aliasing warnings, apparently clang explicitly passes -fno-strict-aliasing to the compiler. However, Fedora RPM %{optflags} are inserted after -fno-strict-aliasing, so I guess the -O2 from %{optflags} negates the explicit -fno-strict-aliasing.

In the mean time, I've built llvm-3.0-10 with -fno-tree-pre that should work around the crash for now.

P.S. Some more info about the same clang segfault is at https://bugzilla.redhat.com/show_bug.cgi?id=800478

Comment 6 Jakub Jelinek 2012-03-26 17:29:29 UTC
No, -fno-strict-aliasing -O2 doesn't enable strict aliasing, -O2 turns it on only when -f{,no-}strict-aliasing isn't explicit, otherwise only
-fno-strict-aliasing -O2 -fstrict-aliasing
would turn it back on.

Comment 7 Fedora Update System 2012-03-26 17:54:46 UTC
llvm-3.0-10.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/llvm-3.0-10.fc17

Comment 8 Fedora Update System 2012-03-28 06:00:21 UTC
Package llvm-3.0-10.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing llvm-3.0-10.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-4812/llvm-3.0-10.fc17
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2012-04-12 03:21:45 UTC
llvm-3.0-10.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.