Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash with old Clang #1179

Closed
sergemeynard-triton opened this issue Jul 30, 2018 · 9 comments
Closed

Compiler crash with old Clang #1179

sergemeynard-triton opened this issue Jul 30, 2018 · 9 comments
Assignees
Milestone

Comments

@sergemeynard-triton
Copy link

I am building the library using Clang 3.4.2 (I don't currently have access to a more recent version) and it is crashing the compiler. The crash goes away if I disable the specialization of std::swap at line 17194, and my app still seems to work properly, but I wanted to get a second opinion about how safe this patch actually is...

@nlohmann
Copy link
Owner

How does the exact error message look like?

@sergemeynard-triton
Copy link
Author

[exec] 0 libLLVM-3.4.so 0x00007f42384485d2 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
[exec] 1 libLLVM-3.4.so 0x00007f4238448dfa
[exec] 2 libpthread.so.0 0x00007f42372a77e0
[exec] 3 clang 0x0000000000bb3a76
[exec] 4 clang 0x0000000000bb441d
[exec] 5 clang 0x0000000000bb4833
[exec] 6 clang 0x0000000000bb4c8a
[exec] 7 clang 0x0000000000bb1f54 clang::Sema::AddOverloadCandidate(clang::FunctionDecl*, clang::DeclAccessPair, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool, bool, bool) + 1188
[exec] 8 clang 0x0000000000bb245d clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool) + 685
[exec] 9 clang 0x0000000000bbf2c6 clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRefclang::Expr*, clang::OverloadCandidateSet&, bool) + 262
[exec] 10 clang 0x0000000000bbf505 clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>) + 325
[exec] 11 clang 0x0000000000bc648c clang::Sema::BuildOverloadedCallExpr(clang::Scope
, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*, bool) + 332
[exec] 12 clang 0x0000000000afc7d3 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*, bool) + 1187
[exec] 13 clang 0x0000000000c8fe91
[exec] 14 clang 0x0000000000c73955
[exec] 15 clang 0x0000000000c7ce62
[exec] 16 clang 0x0000000000c7d95c
[exec] 17 clang 0x0000000000c7443d
[exec] 18 clang 0x0000000000c77e05
[exec] 19 clang 0x0000000000c7bc6b
[exec] 20 clang 0x0000000000c7bdff
[exec] 21 clang 0x0000000000c7cc3e
[exec] 22 clang 0x0000000000c7d95c
[exec] 23 clang 0x0000000000c7e33d clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) + 93
[exec] 24 clang 0x0000000000c7e7ce clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) + 1118
[exec] 25 clang 0x0000000000c871cc clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) + 700
[exec] 26 clang 0x0000000000c890b8 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) + 3016
[exec] 27 clang 0x0000000000cc77ac clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 1708
[exec] 28 clang 0x0000000000cc78ee clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 30
[exec] 29 clang 0x0000000000a732d4 clang::Sema::CheckBaseSpecifier(clang::CXXRecordDecl*, clang::SourceRange, bool, clang::AccessSpecifier, clang::TypeSourceInfo*, clang::SourceLocation) + 2116
[exec] 30 clang 0x0000000000c7e824 clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) + 1204
[exec] 31 clang 0x0000000000c871cc clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) + 700
[exec] 32 clang 0x0000000000c890b8 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) + 3016
[exec] 33 clang 0x0000000000cc77ac clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 1708
[exec] 34 clang 0x0000000000cc78ee clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 30
[exec] 35 clang 0x0000000000a732d4 clang::Sema::CheckBaseSpecifier(clang::CXXRecordDecl*, clang::SourceRange, bool, clang::AccessSpecifier, clang::TypeSourceInfo*, clang::SourceLocation) + 2116
[exec] 36 clang 0x0000000000c7e824 clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) + 1204
[exec] 37 clang 0x0000000000c871cc clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) + 700
[exec] 38 clang 0x0000000000c890b8 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) + 3016
[exec] 39 clang 0x0000000000cc77ac clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 1708
[exec] 40 clang 0x0000000000cc78ee clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 30
[exec] 41 clang 0x0000000000977f49 clang::Sema::RequireCompleteDeclContext(clang::CXXScopeSpec&, clang::DeclContext*) + 313
[exec] 42 clang 0x0000000000af1026 clang::Sema::BuildQualifiedDeclarationNameExpr(clang::CXXScopeSpec&, clang::DeclarationNameInfo const&, bool) + 102
[exec] 43 clang 0x0000000000c6b3a8
[exec] 44 clang 0x0000000000c84f33
[exec] 45 clang 0x0000000000c8501b
[exec] 46 clang 0x0000000000c73a97
[exec] 47 clang 0x0000000000c743a1
[exec] 48 clang 0x0000000000c77e05
[exec] 49 clang 0x0000000000c7c86f
[exec] 50 clang 0x0000000000c7d95c
[exec] 51 clang 0x0000000000c7e33d clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) + 93
[exec] 52 clang 0x0000000000c7e7ce clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) + 1118
[exec] 53 clang 0x0000000000c871cc clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) + 700
[exec] 54 clang 0x0000000000c890b8 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) + 3016
[exec] 55 clang 0x0000000000cc77ac clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 1708
[exec] 56 clang 0x0000000000cc78ee clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 30
[exec] 57 clang 0x0000000000a732d4 clang::Sema::CheckBaseSpecifier(clang::CXXRecordDecl*, clang::SourceRange, bool, clang::AccessSpecifier, clang::TypeSourceInfo*, clang::SourceLocation) + 2116
[exec] 58 clang 0x0000000000c7e824 clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) + 1204
[exec] 59 clang 0x0000000000c871cc clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) + 700
[exec] 60 clang 0x0000000000c890b8 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) + 3016
[exec] 61 clang 0x0000000000cc77ac clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 1708
[exec] 62 clang 0x0000000000cc78ee clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) + 30
[exec] 63 clang 0x0000000000977f49 clang::Sema::RequireCompleteDeclContext(clang::CXXScopeSpec&, clang::DeclContext*) + 313
[exec] 64 clang 0x00000000009f6f6d clang::Sema::getTypeName(clang::IdentifierInfo const&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, bool, bool, clang::OpaquePtrclang::QualType, bool, bool, clang::IdentifierInfo**) + 2349
[exec] 65 clang 0x00000000008d387b clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool, bool, clang::CXXScopeSpec&, bool) + 331
[exec] 66 clang 0x00000000008d4099 clang::Parser::TryAnnotateTypeOrScopeToken(bool, bool) + 169
[exec] 67 clang 0x0000000000906a3c clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState) + 5964
[exec] 68 clang 0x0000000000906c0d clang::Parser::ParseCastExpression(bool, bool, clang::Parser::TypeCastState) + 29
[exec] 69 clang 0x000000000090c68d clang::Parser::ParseConstantExpression(clang::Parser::TypeCastState) + 61
[exec] 70 clang 0x00000000008f583b clang::Parser::tryParseExceptionSpecification(clang::SourceRange&, llvm::SmallVectorImpl<clang::OpaquePtrclang::QualType >&, llvm::SmallVectorImplclang::SourceRange&, clang::ActionResult<clang::Expr*, true>&) + 555
[exec] 71 clang 0x00000000008ed815 clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) + 3013
[exec] 72 clang 0x00000000008ee5e5 clang::Parser::ParseDirectDeclarator(clang::Declarator&) + 1221
[exec] 73 clang 0x00000000008e4c17 clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::)(clang::Declarator&)) + 535
[exec] 74 clang 0x00000000009434fa clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList
) + 1514
[exec] 75 clang 0x0000000000944c05 clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 741
[exec] 76 clang 0x0000000000944f9f clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 143
[exec] 77 clang 0x00000000008eba3e clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 766
[exec] 78 clang 0x00000000008d2e5e clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 1374
[exec] 79 clang 0x00000000008f48d3 clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation, std::allocatorclang::SourceLocation >&, std::vector<clang::IdentifierInfo*, std::allocatorclang::IdentifierInfo* >&, std::vector<clang::SourceLocation, std::allocatorclang::SourceLocation >&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) + 387
[exec] 80 clang 0x00000000008f7509 clang::Parser::ParseNamespace(unsigned int, clang::SourceLocation&, clang::SourceLocation) + 3785
[exec] 81 clang 0x00000000008eba94 clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 852
[exec] 82 clang 0x00000000008d2e5e clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 1374
[exec] 83 clang 0x00000000008d3565 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) + 181
[exec] 84 clang 0x00000000008c9e4b clang::ParseAST(clang::Sema&, bool, bool) + 459
[exec] 85 clang 0x000000000073ab46 clang::CodeGenAction::ExecuteAction() + 70
[exec] 86 clang 0x00000000005bccf2 clang::FrontendAction::Execute() + 210
[exec] 87 clang 0x00000000005982cd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 285
[exec] 88 clang 0x000000000057dc5a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1642
[exec] 89 clang 0x0000000000573bc0 cc1_main(char const**, char const**, char const*, void*) + 1184
[exec] 90 clang 0x000000000057c264 main + 7636
[exec] 91 libc.so.6 0x00007f4235f4dd1d __libc_start_main + 253
[exec] 92 clang 0x0000000000573529

clang: error: unable to execute command: Segmentation fault (core dumped)

@nlohmann
Copy link
Owner

@sergemeynard-triton
Copy link
Author

Yes, I believe that's the one. I wrapped the whole thing inside a #ifndef JSON_DISABLE_SWAP_SPECIALIZATION so I could turn it on or off easily from the including file.

@stale
Copy link

stale bot commented Sep 14, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Sep 14, 2018
@LEgregius
Copy link

LEgregius commented Sep 18, 2018

I was having the same problem, and I found that if I simply move the swap down under the less specialization, the crash goes away. ¯_(ツ)_/¯

@stale stale bot removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Sep 18, 2018
@nlohmann
Copy link
Owner

@LEgregius Could you provide more details on the fix?

@evilsquirrel Could you try the idea from #1179 (comment)?

@sergemeynard-triton
Copy link
Author

sergemeynard-triton commented Sep 19, 2018 via email

@LEgregius
Copy link

LEgregius commented Sep 19, 2018

I forked it and made modified version. I'll make a pull request a bit later.

nlohmann added a commit that referenced this issue Sep 22, 2018
#1179 Reordered the code. It seems to stop clang 3.4.2 in RHEL 7 from crash…
@nlohmann nlohmann self-assigned this Sep 22, 2018
@nlohmann nlohmann added this to the Release 3.2.1 milestone Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants