Bug 800478 - clang segfaults while gcc compiles without errors
clang segfaults while gcc compiles without errors
Product: Fedora
Classification: Fedora
Component: llvm (Show other bugs)
x86_64 Linux
high Severity unspecified
: ---
: ---
Assigned To: Michel Alexandre Salim
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-03-06 09:33 EST by Michal Toman
Modified: 2015-03-22 20:41 EDT (History)
8 users (show)

See Also:
Fixed In Version: llvm-3.0-10.fc17
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-04-11 23:21:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Preprocessed source (19.52 KB, text/x-csrc)
2012-03-06 09:33 EST, Michal Toman
no flags Details

  None (edit)
Description Michal Toman 2012-03-06 09:33:09 EST
Created attachment 567970 [details]
Preprocessed source

Description of problem:
When trying to rebuild some Fedora packages using LLVM/clang instead of GCC, clang segfaults. With LLVM 2.9 several packages could be rebuilt, now I did not find a single one that would pass.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Download the preprocessed source from attachment
2. run "/usr/bin/clang -cc1 -triple x86_64-redhat-linux-gnu -emit-llvm-bc -disable-free -disable-llvm-verifier -main-file-name printf-args.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version -momit-leaf-frame-pointer -v -g -coverage-file printf-args.o -resource-dir /usr/bin/../lib/clang/3.0 -D HAVE_CONFIG_H -D HAVE_LSTAT -I . -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem /usr/include -O0 -Wall -ferror-limit 19 -fmessage-length 0 -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fexceptions -fdiagnostics-show-option -o printf-args.o -x c printf-args.pp.c"
Actual results:
clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-redhat-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
End of search list.
0  libLLVM-3.0.so  0x00007f1f25e1a0bf
1  libLLVM-3.0.so  0x00007f1f25e1a529
2  libpthread.so.0 0x00007f1f2565efb0
3  clang           0x0000000000c5db02
4  clang           0x0000000000c5e4f2
5  clang           0x0000000000c5ecf7
6  clang           0x0000000000c6037d clang::runUninitializedVariablesAnalysis(clang::DeclContext const&, clang::CFG const&, clang::AnalysisContext&, clang::UninitVariablesHandler&, clang::UninitVariablesAnalysisStats&) + 1597
7  clang           0x0000000000af075a clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy, clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::BlockExpr const*) + 970
8  clang           0x00000000008a338c clang::Sema::PopFunctionOrBlockScope(clang::sema::AnalysisBasedWarnings::Policy const*, clang::Decl const*, clang::BlockExpr const*) + 172
9  clang           0x00000000009209ee clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) + 334
10 clang           0x00000000008481e0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 192
11 clang           0x0000000000859564 clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&) + 964
12 clang           0x000000000086e7d7 clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 807
13 clang           0x00000000008532e5 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&, clang::AccessSpecifier) + 149
14 clang           0x0000000000853765 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::AccessSpecifier) + 565
15 clang           0x000000000085718d clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::Parser::ParsingDeclSpec*) + 2157
16 clang           0x00000000008574c0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 144
17 clang           0x0000000000830c0d clang::ParseAST(clang::Sema&, bool) + 269
18 clang           0x00000000007196f3 clang::CodeGenAction::ExecuteAction() + 51
19 clang           0x000000000060f5b3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 307
20 clang           0x00000000005f9524 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 980
21 clang           0x00000000005f1204 cc1_main(char const**, char const**, char const*, void*) + 740
22 clang           0x00000000005f00b8 main + 7096
23 libc.so.6       0x00007f1f24689735 __libc_start_main + 245
24 clang           0x00000000005f0d61
Stack dump:
0.	Program arguments: /usr/bin/clang -cc1 -triple x86_64-redhat-linux-gnu -emit-llvm-bc -disable-free -disable-llvm-verifier -main-file-name printf-args.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version -momit-leaf-frame-pointer -v -g -coverage-file printf-args.o -resource-dir /usr/bin/../lib/clang/3.0 -D HAVE_CONFIG_H -D HAVE_LSTAT -I . -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem /usr/include -O0 -Wall -ferror-limit 19 -fmessage-length 0 -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fexceptions -fdiagnostics-show-option -o printf-args.o -x c printf-args.pp.c 
1.	<eof> parser at end of file
2.	printf-args.c:40:1: parsing function body 'printf_fetchargs'
Segmentation fault

Expected results:
The source compiles with no error.

Additional info:
Source comes from gzip-1.4-6.fc17. The error originates in running from rpmbuild (which appends the flags). A simple LLVM/clang build simulation can be done:
1) download the SRPM (http://kojipkgs.fedoraproject.org/packages/gzip/1.4/6.fc17/src/gzip-1.4-6.fc17.src.rpm)
2) rpm -ivh gzip-1.4-6.fc17.src.rpm
3) add the
"export CC=clang" and
LDFLAGS="-Wl,--plugin,/usr/lib64/llvm/LLVMgold.so -Wl,--plugin-opt,also-emit-llvm"
lines to the beginning of %build section of the specfile
4) switch the linker to ld.gold
5) rpmbuild -bb ~/rpmbuild/SPECS/gzip.spec

Same trick works and produces the error on different simple packages (eg. ncurses, libselinux, btparser), you just eventually need to add "export CXX=clang".
Comment 1 Karel Klíč 2012-03-07 11:42:58 EST
It might be linked to the following upstream bug:


Corresponding two line bugfix can be found in a SVN commit:

Comment 2 Karel Klíč 2012-03-07 11:45:02 EST
Ah, too fast, sorry. This fix is already included in LLVM 3.0
Comment 3 Michal Toman 2012-03-09 03:16:13 EST
After further investigating I found that removing -Wall from flags helps in some (not all) cases.
Comment 4 Fedora Update System 2012-03-26 13:54:40 EDT
llvm-3.0-10.fc17 has been submitted as an update for Fedora 17.
Comment 5 Fedora Update System 2012-03-28 02:00:09 EDT
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:
then log in and leave karma (feedback).
Comment 6 Fedora Update System 2012-04-11 23:21:38 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.