Ericsson / clang

Cross Translation Unit analysis capability for Clang Static Analyzer. (Fork of official clang at http://llvm.org/git/clang)
http://clang.llvm.org/
Other
15 stars 10 forks source link

Assertion `Access != AS_none && "Access specifier is AS_none inside a record decl"' failed. #699

Closed balazske closed 4 years ago

balazske commented 5 years ago

Assertion during analysis of bitcoin with clang master commit 3c10f346dcd and applied patch in D65577.

clang-10: llvm-project/clang/lib/AST/DeclBase.cpp:939: bool clang::Decl::AccessDeclContextSanity() const: Assertion `Access != AS_none && "Access specifier is AS_none inside a record decl"' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007fffec26c801 in __GI_abort () at abort.c:79
#2  0x00007fffec25c39a in __assert_fail_base (fmt=0x7fffec3e37d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7fffe7227ee8 "Access != AS_none && \"Access specifier is AS_none inside a record decl\"",
    file=file@entry=0x7fffe72268e0 "llvm-project/clang/lib/AST/DeclBase.cpp", line=line@entry=939,
    function=function@entry=0x7fffe722d400 <clang::Decl::AccessDeclContextSanity() const::__PRETTY_FUNCTION__> "bool clang::Decl::AccessDeclContextSanity() const") at assert.c:92
#3  0x00007fffec25c412 in __GI___assert_fail (assertion=0x7fffe7227ee8 "Access != AS_none && \"Access specifier is AS_none inside a record decl\"", file=0x7fffe72268e0 "llvm-project/clang/lib/AST/DeclBase.cpp", line=939,
    function=0x7fffe722d400 <clang::Decl::AccessDeclContextSanity() const::__PRETTY_FUNCTION__> "bool clang::Decl::AccessDeclContextSanity() const") at assert.c:101
#4  0x00007fffe6da0284 in clang::Decl::AccessDeclContextSanity (this=0x55557a35e370) at llvm-project/clang/lib/AST/DeclBase.cpp:938
#5  0x00007fffe6b6117c in clang::Decl::getAccess (this=0x55557a35e370) at llvm-project/clang/include/clang/AST/DeclBase.h:474
#6  0x00007fffe6ce7b6a in IsStructurallyEquivalent (Context=..., Method1=0x5555760f8528, Method2=0x55557a35e370) at llvm-project/clang/lib/AST/ASTStructuralEquivalence.cpp:1043
#7  0x00007fffe6ceb609 in clang::StructuralEquivalenceContext::CheckKindSpecificEquivalence (this=0x7ffffffe6f00, D1=0x5555760f8528, D2=0x55557a35e370) at llvm-project/clang/lib/AST/ASTStructuralEquivalence.cpp:1840
#8  0x00007fffe6ceb882 in clang::StructuralEquivalenceContext::Finish (this=0x7ffffffe6f00) at llvm-project/clang/lib/AST/ASTStructuralEquivalence.cpp:1886
#9  0x00007fffe6ceaddb in clang::StructuralEquivalenceContext::IsEquivalent (this=0x7ffffffe6f00, D1=0x5555760f8528, D2=0x55557a35e370) at llvm-project/clang/lib/AST/ASTStructuralEquivalence.cpp:1715
#10 0x00007fffe6b2e78a in clang::ASTNodeImporter::IsStructuralMatch (this=0x7ffffffe73f0, From=0x5555760f8528, To=0x55557a35e370) at llvm-project/clang/lib/AST/ASTImporter.cpp:2082
#11 0x00007fffe6b34c17 in clang::ASTNodeImporter::VisitFunctionDecl (this=0x7ffffffe73f0, D=0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:3082
#12 0x00007fffe6b369c0 in clang::ASTNodeImporter::VisitCXXMethodDecl (this=0x7ffffffe73f0, D=0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:3372
#13 0x00007fffe6b36a14 in clang::ASTNodeImporter::VisitCXXConstructorDecl (this=0x7ffffffe73f0, D=0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:3376
#14 0x00007fffe6bb0adc in clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*> >::Visit (this=0x7ffffffe73f0, D=0x5555760f8528) at tools/clang/include/clang/AST/DeclNodes.inc:409
#15 0x00007fffe6b58a75 in clang::ASTImporter::ImportImpl (this=0x55556cc08fc0, FromD=0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:7884
#16 0x00007fffe6b59543 in clang::ASTImporter::Import (this=0x55556cc08fc0, FromD=0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:7989
#17 0x00007fffe6c359e7 in clang::ASTNodeImporter::import<clang::CXXConstructorDecl> (this=0x7ffffffe7ae0, From=0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:162
#18 0x00007fffe6bf59f5 in clang::ASTNodeImporter::importSeq<clang::CXXConstructorDecl*> (this=0x7ffffffe7ae0, From=@0x7ffffffe7938: 0x5555760f8528) at llvm-project/clang/lib/AST/ASTImporter.cpp:190
#19 0x00007fffe6c3929d in clang::ASTNodeImporter::importSeq<clang::CXXConstructorDecl*, clang::SourceRange> (this=0x7ffffffe7ae0, FromHead=@0x7ffffffe7938: 0x5555760f8528, FromTail#0=...) at llvm-project/clang/lib/AST/ASTImporter.cpp:203
#20 0x00007fffe6bf9ad2 in clang::ASTNodeImporter::importSeq<clang::SourceLocation, clang::CXXConstructorDecl*, clang::SourceRange> (this=0x7ffffffe7ae0, FromHead=..., FromTail#0=@0x7ffffffe7938: 0x5555760f8528, FromTail#1=...)
    at llvm-project/clang/lib/AST/ASTImporter.cpp:206
#21 0x00007fffe6baa6eb in clang::ASTNodeImporter::importSeq<clang::QualType, clang::SourceLocation, clang::CXXConstructorDecl*, clang::SourceRange> (this=0x7ffffffe7ae0, FromHead=..., FromTail#0=..., FromTail#1=@0x7ffffffe7938: 0x5555760f8528, FromTail#2=...)
    at llvm-project/clang/lib/AST/ASTImporter.cpp:206
#22 0x00007fffe6b52295 in clang::ASTNodeImporter::VisitCXXConstructExpr (this=0x7ffffffe7ae0, E=0x5555760f8d18) at llvm-project/clang/lib/AST/ASTImporter.cpp:7136
#23 0x00007fffe6bb3ae4 in clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) (this=0x7ffffffe7ae0, S=0x5555760f8d18) at tools/clang/include/clang/AST/StmtNodes.inc:649
#24 0x00007fffe6b5a678 in clang::ASTImporter::Import (this=0x55556cc08fc0, FromS=0x5555760f8d18) at llvm-project/clang/lib/AST/ASTImporter.cpp:8160
#25 0x00007fffe6b5a4a7 in clang::ASTImporter::Import (this=0x55556cc08fc0, FromE=0x5555760f8d18) at llvm-project/clang/lib/AST/ASTImporter.cpp:8143
#26 0x00007fffe6b83d29 in clang::ASTNodeImporter::import<clang::Expr> (this=0x7ffffffe7d90, From=0x5555760f8d18) at llvm-project/clang/lib/AST/ASTImporter.cpp:162
#27 0x00007fffe6b52618 in clang::ASTNodeImporter::VisitExprWithCleanups (this=0x7ffffffe7d90, E=0x5555760f8d48) at llvm-project/clang/lib/AST/ASTImporter.cpp:7159
#28 0x00007fffe6bb4040 in clang::StmtVisitorBase<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Stmt*>>::Visit(clang::Stmt*) (this=0x7ffffffe7d90, S=0x5555760f8d48) at tools/clang/include/clang/AST/StmtNodes.inc:983
#29 0x00007fffe6b5a678 in clang::ASTImporter::Import (this=0x55556cc08fc0, FromS=0x5555760f8d48) at llvm-project/clang/lib/AST/ASTImporter.cpp:8160
#30 0x00007fffe6b5a4a7 in clang::ASTImporter::Import (this=0x55556cc08fc0, FromE=0x5555760f8d48) at llvm-project/clang/lib/AST/ASTImporter.cpp:8143
#31 0x00007fffe6b5cc32 in clang::ASTImporter::Import (this=0x55556cc08fc0, From=0x5555760f8d60) at llvm-project/clang/lib/AST/ASTImporter.cpp:8520
#32 0x00007fffe6c155b7 in clang::ASTNodeImporter::import<clang::CXXCtorInitializer> (this=0x7ffffffe8470, From=0x5555760f8d60) at llvm-project/clang/lib/AST/ASTImporter.cpp:162
#33 0x00007fffe6bc8d64 in clang::ASTNodeImporter::ImportArrayChecked<clang::CXXCtorInitializer**, clang::CXXCtorInitializer**> (this=0x7ffffffe8470, Ibegin=0x5555760f8ba8, Iend=0x5555760f8bb0, Obegin=0x7ffffffe82e0)
    at llvm-project/clang/lib/AST/ASTImporter.cpp:616
#34 0x00007fffe6b8eed7 in clang::ASTNodeImporter::ImportContainerChecked<llvm::iterator_range<clang::CXXCtorInitializer**>, llvm::SmallVector<clang::CXXCtorInitializer*, 4u> > (this=0x7ffffffe8470, InContainer=..., OutContainer=...)
    at llvm-project/clang/lib/AST/ASTImporter.cpp:632
#35 0x00007fffe6b36006 in clang::ASTNodeImporter::VisitFunctionDecl (this=0x7ffffffe8470, D=0x5555760f80a0) at llvm-project/clang/lib/AST/ASTImporter.cpp:3276
#36 0x00007fffe6b369c0 in clang::ASTNodeImporter::VisitCXXMethodDecl (this=0x7ffffffe8470, D=0x5555760f80a0) at llvm-project/clang/lib/AST/ASTImporter.cpp:3372
#37 0x00007fffe6b36a14 in clang::ASTNodeImporter::VisitCXXConstructorDecl (this=0x7ffffffe8470, D=0x5555760f80a0) at llvm-project/clang/lib/AST/ASTImporter.cpp:3376
#38 0x00007fffe6bb0adc in clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*> >::Visit (this=0x7ffffffe8470, D=0x5555760f80a0) at tools/clang/include/clang/AST/DeclNodes.inc:409
#39 0x00007fffe6b58a75 in clang::ASTImporter::ImportImpl (this=0x55556cc08fc0, FromD=0x5555760f80a0) at llvm-project/clang/lib/AST/ASTImporter.cpp:7884
#40 0x00007fffe6b59543 in clang::ASTImporter::Import (this=0x55556cc08fc0, FromD=0x5555760f80a0) at llvm-project/clang/lib/AST/ASTImporter.cpp:7989
#41 0x00007fffe6b85487 in clang::ASTNodeImporter::import<clang::Decl> (this=0x7ffffffe8c30, From=0x5555760f80a0) at llvm-project/clang/lib/AST/ASTImporter.cpp:162
#42 0x00007fffe6b2c1bf in clang::ASTNodeImporter::ImportDeclContext (this=0x7ffffffe8c30, FromDC=0x55556bb9a080, ForceImport=true) at llvm-project/clang/lib/AST/ASTImporter.cpp:1651
#43 0x00007fffe6b2d96b in clang::ASTNodeImporter::ImportDefinition (this=0x7ffffffe8c30, From=0x55556bb9a040, To=0x55557a35e070, Kind=clang::ASTNodeImporter::IDK_Default) at llvm-project/clang/lib/AST/ASTImporter.cpp:1919
#44 0x00007fffe6b3329c in clang::ASTNodeImporter::VisitRecordDecl (this=0x7ffffffe8c30, D=0x55556bb9a040) at llvm-project/clang/lib/AST/ASTImporter.cpp:2822
balazske commented 5 years ago

It looks like that https://github.com/Ericsson/clang/commit/50346f9fb96c332e7aa730f0169fa9ff4bf195bb is a fix for this problem.

martong commented 5 years ago

It looks like that 50346f9 is a fix for this problem.

Okay, then could you please create a patch on Phab for that change? Possibly with a unittest or with a lit test?

balazske commented 5 years ago

Patch created: https://reviews.llvm.org/D65935

martong commented 5 years ago

Thanks!