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

clang-tidy crash due to readability-static-accessed-through-instance check bug. #53874

Closed
cloudhan opened this issue Feb 16, 2022 · 3 comments
Closed
Labels
clang-tidy confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@cloudhan
Copy link

Run with clang-tidy --checks=readability-static-accessed* on the following file,

struct S {
  constexpr static int i = 1;
} s;

int main() {
  s.i;
}

results in the following error:

Stack dump:
0.      Program arguments: ../build/bin/clang-tidy --checks=readability-static-accessed* bug.cpp
1.      <eof> parser at end of file
 #0 0x00007f3f60113034 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/guangyunhan/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
 #1 0x00007f3f601130eb PrintStackTraceSignalHandler(void*) /home/guangyunhan/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0
 #2 0x00007f3f60110d9a llvm::sys::RunSignalHandlers() /home/guangyunhan/workspaces/llvm-project/llvm/lib/Support/Signals.cpp:97:0
 #3 0x00007f3f601129b5 SignalHandler(int) /home/guangyunhan/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:0
 #4 0x00007f3f65b1e040 (/lib/x86_64-linux-gnu/libc.so.6+0x3f040)
 #5 0x00007f3f609f2604 llvm::PointerIntPair<clang::NestedNameSpecifier*, 2u, clang::NestedNameSpecifier::StoredSpecifierKind, llvm::PointerLikeTypeTraits<clang::NestedNameSpecifier*>, llvm::PointerIntPairInfo<clang::NestedNameSpecifier*, 2u, llvm::PointerLikeTypeTraits<clang::NestedNameSpecifier*> > >::getPointer() const /home/guangyunhan/workspaces/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:60:0
 #6 0x00007f3f609e4384 clang::NestedNameSpecifier::getPrefix() const /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h:169:0
 #7 0x00007f3f60dac5f6 clang::tidy::readability::getNameSpecifierNestingLevel(clang::QualType const&) /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp:26:0
 #8 0x00007f3f60dacb88 clang::tidy::readability::StaticAccessedThroughInstanceCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp:83:0
 #9 0x00007f3f605d3134 clang::tidy::ClangTidyCheck::run(clang::ast_matchers::MatchFinder::MatchResult const&) /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:46:0
#10 0x00007f3f5f456b16 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1060:0
#11 0x00007f3f5f5cc20d clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:105:0
#12 0x00007f3f5f455c06 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:866:0
#13 0x00007f3f5f455e07 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch(clang::Stmt const*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:890:0
#14 0x00007f3f5f46325b void clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::match<clang::Stmt>(clang::Stmt const&) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:719:0
#15 0x00007f3f5f457565 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1260:0
#16 0x00007f3f5f497567 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseCompoundStmt(clang::CompoundStmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2268:0
#17 0x00007f3f5f4611b7 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::dataTraverseNode(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) /home/guangyunhan/workspaces/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:73:0
#18 0x00007f3f5f454bfa clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::dataTraverseNode(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:590:0
#19 0x00007f3f5f465ed5 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:605:0
#20 0x00007f3f5f45757c clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1260:0
#21 0x00007f3f5f517025 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionHelper(clang::FunctionDecl*) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2100:0
#22 0x00007f3f5f4bc275 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionDecl(clang::FunctionDecl*) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:2111:0
#23 0x00007f3f5f46551f clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) /home/guangyunhan/workspaces/llvm-project/build/tools/clang/include/clang/AST/DeclNodes.inc:421:0
#24 0x00007f3f5f4574aa clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1248:0
#25 0x00007f3f5f515098 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1397:0
#26 0x00007f3f5f4c0216 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1498:0
#27 0x00007f3f5f465b19 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) /home/guangyunhan/workspaces/llvm-project/build/tools/clang/include/clang/AST/DeclNodes.inc:621:0
#28 0x00007f3f5f4574aa clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1248:0
#29 0x00007f3f5f46b697 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseAST(clang::ASTContext&) /home/guangyunhan/workspaces/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:201:0
#30 0x00007f3f5f458460 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1476:0
#31 0x00007f3f5f457915 clang::ast_matchers::internal::(anonymous namespace)::MatchASTConsumer::HandleTranslationUnit(clang::ASTContext&) /home/guangyunhan/workspaces/llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1340:0
#32 0x00007f3f5a4088fe clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /home/guangyunhan/workspaces/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp:291:0
#33 0x00007f3f527f6c3c clang::ParseAST(clang::Sema&, bool, bool) /home/guangyunhan/workspaces/llvm-project/clang/lib/Parse/ParseAST.cpp:178:0
#34 0x00007f3f5a3d12df clang::ASTFrontendAction::ExecuteAction() /home/guangyunhan/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1074:0
#35 0x00007f3f5a3d0ba8 clang::FrontendAction::Execute() /home/guangyunhan/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:971:0
#36 0x00007f3f5a2823fd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/guangyunhan/workspaces/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1036:0
#37 0x00007f3f603eeeff clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/guangyunhan/workspaces/llvm-project/clang/lib/Tooling/Tooling.cpp:423:0
#38 0x00007f3f60579243 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:567:0
#39 0x00007f3f603eed2f clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /home/guangyunhan/workspaces/llvm-project/clang/lib/Tooling/Tooling.cpp:399:0
#40 0x00007f3f603eeb44 clang::tooling::ToolInvocation::run() /home/guangyunhan/workspaces/llvm-project/clang/lib/Tooling/Tooling.cpp:384:0
#41 0x00007f3f603f03eb clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /home/guangyunhan/workspaces/llvm-project/clang/lib/Tooling/Tooling.cpp:577:0
#42 0x00007f3f60579682 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:588:0
#43 0x00007f3f660d167e clang::tidy::clangTidyMain(int, char const**) /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:501:0
#44 0x00005649852e88ba main /home/guangyunhan/workspaces/llvm-project/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp:21:0
#45 0x00007f3f65b00bf7 __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
@EugeneZelenko EugeneZelenko added clang-tidy confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Feb 16, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 16, 2022

@llvm/issue-subscribers-clang-tidy

@junaire
Copy link
Member

junaire commented Feb 16, 2022

A potential fix: https://reviews.llvm.org/D119949

cloudhan added a commit to cloudhan/onnxruntime that referenced this issue Feb 25, 2022
cloudhan added a commit to microsoft/onnxruntime that referenced this issue Feb 28, 2022
cloudhan added a commit to microsoft/onnxruntime that referenced this issue Mar 1, 2022
junaire added a commit that referenced this issue Mar 1, 2022
The ElaboratedType can have no qualifiers, so we should check it before
use.

Fix #issue53874(#53874)

Differential Revision: https://reviews.llvm.org/D119949
@junaire
Copy link
Member

junaire commented Mar 1, 2022

Close via ac616fb

@junaire junaire closed this as completed Mar 1, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
The ElaboratedType can have no qualifiers, so we should check it before
use.

Fix #issue53874(llvm/llvm-project#53874)

Differential Revision: https://reviews.llvm.org/D119949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants