llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.12k stars 11.61k forks source link

Clang crashes when compiling a source file with precompiled headers #17862

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 17488
Version 3.2
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

Hi there,

Clang crashes for me when compiling one of my project's source files. I tested both clang 3.2 from the Debian repository as well as the latest clang 3.4 trunk (rev 192067) build. I get no errors on that file with gcc 4.8.1 and MS cl 18.0. Here is what I get from Debian's clang 3.2:

0 libLLVM-3.2.so.1 0x00002aaaaba0f67f 1 libLLVM-3.2.so.1 0x00002aaaaba0fae9 2 libpthread.so.0 0x00002aaaac407bd0 3 clang 0x0000000000f6cc3c 4 clang 0x0000000000f6cdb2 5 clang 0x0000000000f6d324 6 clang 0x0000000000f6ecf5 7 clang 0x0000000000f6d4b4 8 clang 0x0000000000f6f0cc clang::Stmt::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&, bool) const + 28 9 clang 0x0000000000e7d863 clang::ASTContext::getDecltypeType(clang::Expr, clang::QualType) const + 131 10 clang 0x0000000000696b89 clang::ASTReader::readTypeRecord(unsigned int) + 2393 11 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 12 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 13 clang 0x00000000006968a8 clang::ASTReader::readTypeRecord(unsigned int) + 1656 14 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 15 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 16 clang 0x00000000006c59fb clang::ASTDeclReader::VisitValueDecl(clang::ValueDecl) + 75 17 clang 0x00000000006c5bcf clang::ASTDeclReader::VisitDeclaratorDecl(clang::DeclaratorDecl) + 15 18 clang 0x00000000006c6fe4 clang::ASTDeclReader::VisitFunctionDecl(clang::FunctionDecl) + 180 19 clang 0x00000000006c81a5 clang::ASTDeclReader::VisitCXXMethodDecl(clang::CXXMethodDecl) + 21 20 clang 0x00000000006cb315 clang::ASTDeclReader::Visit(clang::Decl) + 325 21 clang 0x00000000006cb93f clang::ASTReader::ReadDeclRecord(unsigned int) + 607 22 clang 0x00000000006905e7 clang::ASTReader::GetDecl(unsigned int) + 119 23 clang 0x00000000006c2fb0 clang::ASTDeclReader::VisitDecl(clang::Decl) + 96 24 clang 0x00000000006c4429 clang::ASTDeclReader::VisitNamedDecl(clang::NamedDecl) + 25 25 clang 0x00000000006c59c1 clang::ASTDeclReader::VisitValueDecl(clang::ValueDecl) + 17 26 clang 0x00000000006c5bcf clang::ASTDeclReader::VisitDeclaratorDecl(clang::DeclaratorDecl) + 15 27 clang 0x00000000006c655d clang::ASTDeclReader::VisitVarDecl(clang::VarDecl) + 157 28 clang 0x00000000006c690f clang::ASTDeclReader::VisitParmVarDecl(clang::ParmVarDecl) + 15 29 clang 0x00000000006cb2a5 clang::ASTDeclReader::Visit(clang::Decl) + 213 30 clang 0x00000000006cb93f clang::ASTReader::ReadDeclRecord(unsigned int) + 607 31 clang 0x00000000006905e7 clang::ASTReader::GetDecl(unsigned int) + 119 32 clang 0x00000000006ddd4b clang::ASTStmtReader::VisitDeclRefExpr(clang::DeclRefExpr) + 363 33 clang 0x00000000006de4c8 clang::ASTReader::ReadStmtFromStream(clang::serialization::ModuleFile&) + 1176 34 clang 0x0000000000696b7a clang::ASTReader::readTypeRecord(unsigned int) + 2378 35 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 36 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 37 clang 0x000000000069ba8a clang::ASTReader::ReadTemplateArgument(clang::serialization::ModuleFile&, llvm::SmallVector<unsigned long, 64u> const&, unsigned int&) + 490 38 clang 0x0000000000696205 clang::ASTReader::ReadTemplateArgumentList(llvm::SmallVector<clang::TemplateArgument, 8u>&, clang::serialization::ModuleFile&, llvm::SmallVector<unsigned long, 64u> const&, unsigned int&) + 181 39 clang 0x0000000000697769 clang::ASTReader::readTypeRecord(unsigned int) + 5433 40 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 41 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 42 clang 0x0000000000697b45 clang::ASTReader::readTypeRecord(unsigned int) + 6421 43 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 44 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 45 clang 0x0000000000698984 clang::ASTReader::ReadNestedNameSpecifier(clang::serialization::ModuleFile&, llvm::SmallVector<unsigned long, 64u> const&, unsigned int&) + 404 46 clang 0x00000000006970b2 clang::ASTReader::readTypeRecord(unsigned int) + 3714 47 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 48 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 49 clang 0x00000000006968a8 clang::ASTReader::readTypeRecord(unsigned int) + 1656 50 clang 0x00000000006983ea clang::ASTReader::GetType(unsigned int) + 202 51 clang 0x00000000006987e3 clang::ASTReader::getLocalType(clang::serialization::ModuleFile&, unsigned int) + 19 52 clang 0x00000000006c59fb clang::ASTDeclReader::VisitValueDecl(clang::ValueDecl) + 75 53 clang 0x00000000006c5bcf clang::ASTDeclReader::VisitDeclaratorDecl(clang::DeclaratorDecl) + 15 54 clang 0x00000000006c6fe4 clang::ASTDeclReader::VisitFunctionDecl(clang::FunctionDecl) + 180 55 clang 0x00000000006c81a5 clang::ASTDeclReader::VisitCXXMethodDecl(clang::CXXMethodDecl) + 21 56 clang 0x00000000006cb315 clang::ASTDeclReader::Visit(clang::Decl) + 325 57 clang 0x00000000006cb93f clang::ASTReader::ReadDeclRecord(unsigned int) + 607 58 clang 0x00000000006905e7 clang::ASTReader::GetDecl(unsigned int) + 119 59 clang 0x00000000006c448f clang::ASTDeclReader::VisitTemplateDecl(clang::TemplateDecl) + 63 60 clang 0x00000000006c8c60 clang::ASTDeclReader::VisitRedeclarableTemplateDecl(clang::RedeclarableTemplateDecl) + 224 61 clang 0x00000000006c8e29 clang::ASTDeclReader::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl) + 25 62 clang 0x00000000006cb445 clang::ASTDeclReader::Visit(clang::Decl) + 629 63 clang 0x00000000006cb93f clang::ASTReader::ReadDeclRecord(unsigned int) + 607 64 clang 0x00000000006905e7 clang::ASTReader::GetDecl(unsigned int) + 119 65 clang 0x0000000000690944 66 clang 0x00000000007209ac clang::serialization::ModuleManager::visitDepthFirst(bool ()(clang::serialization::ModuleFile&, bool, void), void) + 188 67 clang 0x000000000068648a clang::ASTReader::FindExternalLexicalDecls(clang::DeclContext const, bool ()(clang::Decl::Kind), llvm::SmallVectorImpl<clang::Decl>&) + 74 68 clang 0x0000000000ed9101 clang::DeclContext::LoadLexicalDeclsFromExternalStorage() const + 113 69 clang 0x0000000000ed921f clang::DeclContext::decls_begin() const + 15 70 clang 0x0000000000b2fc25 clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl, clang::CXXRecordDecl, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) + 917 71 clang 0x0000000000b31395 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl, clang::TemplateSpecializationKind, bool) + 1237 72 clang 0x0000000000b5f565 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 1189 73 clang 0x0000000000a23e89 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr>, clang::SourceLocation) + 489 74 clang 0x0000000000b25f58 75 clang 0x0000000000b3b72b 76 clang 0x0000000000b26020 77 clang 0x0000000000b38c45 78 clang 0x0000000000b39466 79 clang 0x0000000000b38092 80 clang 0x0000000000b37cf4 81 clang 0x0000000000b39466 82 clang 0x0000000000b38092 83 clang 0x0000000000b39def clang::Sema::SubstStmt(clang::Stmt, clang::MultiLevelTemplateArgumentList const&) + 79 84 clang 0x0000000000b4d93a clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 1082 85 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 86 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 87 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 88 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 89 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 90 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 91 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 92 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 93 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 94 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 95 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 96 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 97 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 98 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 99 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 100 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 101 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 102 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 103 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 104 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 105 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 106 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 107 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 108 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 109 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 110 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 111 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 112 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 113 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 114 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 115 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 116 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 117 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 118 clang 0x0000000000b4dcea clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl, bool, bool) + 2026 119 clang 0x0000000000b4cd2e clang::Sema::PerformPendingInstantiations(bool) + 494 120 clang 0x00000000008e1903 clang::Sema::ActOnEndOfTranslationUnit() + 2323 121 clang 0x0000000000861613 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&) + 387 122 clang 0x0000000000859afb clang::ParseAST(clang::Sema&, bool, bool) + 267 123 clang 0x00000000005f50b1 clang::FrontendAction::Execute() + 97 124 clang 0x00000000005dc57a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 282 125 clang 0x00000000005c5e92 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 1378 126 clang 0x00000000005c0e88 cc1_main(char const, char const, char const, void) + 1160 127 clang 0x00000000005bfd84 main + 7316 128 libc.so.6 0x00002aaaacb50ea5 __libc_start_main + 245 129 clang 0x00000000005c0889 Stack dump:

  1. Program arguments: /usr/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name translator.cpp -mrelocation-model pic -pic-level 2 -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.23.2 -momit-leaf-frame-pointer -coverage-file /home/somebody/dev-git/shift/build/source/protogen/CMakeFiles/shift.protogen.dir/translator.cpp.o -resource-dir /usr/bin/../lib/clang/3.2 -include-pch /home/somebody/dev-git/shift/build/source/protogen/shift.protogen.pch/precompiled.h.gch -D BOOST_ALL_NO_LIB -D BOOST_SPIRIT_USE_PHOENIX_V3 -D BOOST_THREAD_USE_LIB=1 -D PLATFORM_LINUX -I /home/somebody/dev-git/shift/build/source/protogen -I /home/somebody/dev-git/shift/source/protogen -I /home/somebody/dev-git/shift/3rdparty/linux-x86_64-clang3.2/include -I /home/somebody/dev-git/shift/3rdparty/linux-x86_64-clang3.2/include/boost-1_54 -I /home/somebody/dev-git/shift/source -I /usr/include/c++/v1 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.2/include -internal-isystem /usr/include/clang/3.2/include/ -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include -O3 -Winvalid-pch -fdeprecated-macro -fdebug-compilation-dir /home/somebody/dev-git/shift/build/source/protogen -ferror-limit 19 -ftemplate-backtrace-limit 0 -fmessage-length 152 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -std=c++11 -o CMakeFiles/shift.protogen.dir/translator.cpp.o -x c++ /home/somebody/dev-git/shift/source/protogen/translator.cpp
  2. parser at end of file
  3. /home/somebody/dev-git/shift/source/protogen/grammar.h:33:5: instantiating function definition 'Grammar'
  4. /usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:218:15: instantiating function definition 'operator='
  5. /usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:180:21: instantiating function definition 'define'
  6. /usr/include/boost/function/function_template.hpp:1122:3: instantiating function definition 'operator='
  7. /usr/include/boost/function/function_template.hpp:1061:3: instantiating function definition 'function'
  8. /usr/include/boost/function/function_template.hpp:712:5 <Spelling=:8:1>: instantiating function definition 'function4'
  9. /usr/include/boost/function/function_template.hpp:915:10: instantiating function definition 'assign_to'
  10. /usr/include/boost/function/function_template.hpp:123:18: instantiating function definition 'invoke'
  11. /usr/include/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp:47:14: instantiating function definition 'operator()'
  12. /usr/include/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp:28:14: instantiating function definition 'call'
  13. /usr/include/boost/spirit/home/qi/operator/sequence_base.hpp:119:14: instantiating function definition 'parse'
  14. /usr/include/boost/spirit/home/qi/operator/sequence_base.hpp:69:14: instantiating function definition 'parse_impl'
  15. /usr/include/boost/spirit/home/support/algorithm/any_if.hpp:212:5: instantiating function definition 'any_if'
  16. /usr/include/boost/fusion/algorithm/query/any.hpp:28:5: instantiating function definition 'any'
  17. /usr/include/boost/fusion/algorithm/query/detail/any.hpp:47:5: instantiating function definition 'any'
  18. /usr/include/boost/fusion/algorithm/query/detail/any.hpp:34:5: instantiating function definition 'linear_any'
  19. /usr/include/boost/spirit/home/qi/detail/expect_function.hpp:67:14: instantiating function definition 'operator()'
  20. /usr/include/boost/spirit/home/qi/action/action.hpp:50:14: instantiating function definition 'parse' clang: error: unable to execute command: Segmentation fault clang: error: clang frontend command failed due to signal (use -v to see invocation) Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2) Target: x86_64-pc-linux-gnu Thread model: posix clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang: note: diagnostic msg:

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/translator-RPgBXq.cpp clang: note: diagnostic msg: /tmp/translator-RPgBXq.sh clang: note: diagnostic msg:


make[2]: [source/protogen/CMakeFiles/shift.protogen.dir/translator.cpp.o] Error 254 make[1]: [source/protogen/CMakeFiles/shift.protogen.dir/all] Error 2 make: *** [all] Error 2

llvmbot commented 10 years ago

Ok I narrowed down the issue: Clang only crashes when using precompiled headers.

llvmbot commented 10 years ago

I just noticed that the automatically generated pre-processed source code file is kinda useless because it is missing several headers... So I tried to manually get the pre-processed source by adding -E to the call I got from "VERBOSE=1 make". Unfortunately, when trying to compile that pre-processed file I do get regular compile errors in some 3rd party library header. I don't see an easy way to give you code to reproduce the error above =(.

llvmbot commented 10 years ago

Sorry, it seems that I cannot upload the file here as it is too big. Here are the links the the preprocessed source file and sh file in question:

https://boxie.eu/translator-RPgBXq.cpp https://boxie.eu/translator-RPgBXq.sh

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend