-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Crash in modernize-use-ranges check #100406
Comments
@llvm/issue-subscribers-clang-tidy Author: None (matthew-f)
The modernize-use-ranges check is crashing. This is the backtrace:
```
1. <eof> parser at end of file
2. ASTMatcher: Processing 'modernize-use-ranges' against:
CallExpr : </home/xxx/xxx/source/trunk/500_tmp/enterprise/cloud/servers/user/logins.cpp:241:4, line:243:31>
--- Bound Nodes Begin ---
ArgName0 - { DeclRefExpr : </home/xxx/xxx/source/trunk/500_tmp/enterprise/cloud/servers/user/logins.cpp:241:16> }
CallExpr0:2:0 - { CallExpr : </home/xxx/xxx/source/trunk/500_tmp/enterprise/cloud/servers/user/logins.cpp:241:4, line:243:31> }
FuncDecl - { FunctionDecl std::_V2::rotate : </usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algo.h:1403:5 <Spelling=/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11/bits/c++config.h:169:32>, /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algo.h:1416:5> }
--- Bound Nodes End ---
#0 0x000059a2eef79530 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/llvm-20240723/bin/clang-tidy+0x48f6530)
#1 0x000059a2eef76b0e SignalHandler(int) Signals.cpp:0:0
#2 0x0000768f8a242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000059a2ebfb09bc clang::tidy::utils::UseRangesCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/local/llvm-20240723/bin/clang-tidy+0x192d9bc)
#4 0x000059a2edab7e36 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
#5 0x000059a2edae5b8f clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/usr/local/llvm-20240723/bin/clang-tidy+0x3462b8f)
#6 0x000059a2edab8a30 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#7 0x000059a2edadd4d0 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseObjCAvailabilityCheckExpr(clang::ObjCAvailabilityCheckExpr*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) ASTMatchFinder.cpp:0:0
#8 0x000059a2edad5950 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*>>>>*) ASTMatchFinder.cpp:0:0
#9 0x000059a2edad5adb 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*>>>>*) (.constprop.0) ASTMatchFinder.cpp:0:0
#10 0x000059a2edadf90f clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionHelper(clang::FunctionDecl*) ASTMatchFinder.cpp:0:0
#11 0x000059a2edadfb83 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseCXXMethodDecl(clang::CXXMethodDecl*) ASTMatchFinder.cpp:0:0
#12 0x000059a2edad02cf clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#13 0x000059a2edad03d9 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) ASTMatchFinder.cpp:0:0
#14 0x000059a2edadbad8 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#15 0x000059a2edad02cf clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#16 0x000059a2edad0605 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/usr/local/llvm-20240723/bin/clang-tidy+0x344d605)
#17 0x000059a2ec84a900 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/llvm-20240723/bin/clang-tidy+0x21c7900)
#18 0x000059a2ecad633c clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/llvm-20240723/bin/clang-tidy+0x245333c)
#19 0x000059a2ec80a449 clang::FrontendAction::Execute() (/usr/local/llvm-20240723/bin/clang-tidy+0x2187449)
#20 0x000059a2ec777c39 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/llvm-20240723/bin/clang-tidy+0x20f4c39)
#21 0x000059a2ec01ca04 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/local/llvm-20240723/bin/clang-tidy+0x1999a04)
#22 0x000059a2ebfbe9fe 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*) ClangTidy.cpp:0:0
#23 0x000059a2ec016035 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/local/llvm-20240723/bin/clang-tidy+0x1993035)
#24 0x000059a2ec0185db clang::tooling::ToolInvocation::run() (/usr/local/llvm-20240723/bin/clang-tidy+0x19955db)
#25 0x000059a2ec01a78f clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/local/llvm-20240723/bin/clang-tidy+0x199778f)
#26 0x000059a2ebfc7dea 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) (/usr/local/llvm-20240723/bin/clang-tidy+0x1944dea)
#27 0x000059a2eb23425a clang::tidy::clangTidyMain(int, char const**) (/usr/local/llvm-20240723/bin/clang-tidy+0xbb125a)
#28 0x0000768f8a229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#29 0x0000768f8a229e40 call_init ./csu/../csu/libc-start.c:128:20
#30 0x0000768f8a229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#31 0x000059a2eb22a4d5 _start (/usr/local/llvm-20240723/bin/clang-tidy+0xba74d5)
Segmentation fault (core dumped)
```
The problem is the 'Qualified name is not found in 'Replaces'. As a hack, this fixes it:
In the instance when it crashed, the 'Qualified' name was I don't know this code at all, and from the assert it looks like this is not expected, so I'm afraid I'm not submitting a proper fix. |
Sounds like the issue is its not properly handling inline namespaces |
@matthew-f If you wouldn't mind could you test that linked MR. I wasn't able to reproduce the crash with the test cases, but it seems like it should be fixed |
Hi @njames93 . That fix does work on my test case. Thank you. |
Crash seems to be caused by the check function not handling inline namespaces correctly for some instances. Changed how the Replacer is got from the MatchResult now which should alleviate any potential issues Fixes #100406
Summary: Crash seems to be caused by the check function not handling inline namespaces correctly for some instances. Changed how the Replacer is got from the MatchResult now which should alleviate any potential issues Fixes #100406 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250581
Should this still be backported to 19? in that case someone needs to request a PR. |
Yes, it need. |
Can the fix from the linked PR not simply be cherry picked? |
In order for the release managers to keep up with the number of fixes that should be merged we want people to follow these instructions - https://llvm.org/docs/GitHub.html#backporting-fixes-to-the-release-branches |
Crash seems to be caused by the check function not handling inline namespaces correctly for some instances. Changed how the Replacer is got from the MatchResult now which should alleviate any potential issues Fixes llvm#100406 (cherry picked from commit 0762db6)
/pull-request #101482 |
Crash seems to be caused by the check function not handling inline namespaces correctly for some instances. Changed how the Replacer is got from the MatchResult now which should alleviate any potential issues Fixes llvm#100406 (cherry picked from commit 0762db6)
The modernize-use-ranges check is crashing. This is the backtrace:
The problem is the 'Qualified name is not found in 'Replaces'. As a hack, this fixes it:
In the instance when it crashed, the 'Qualified' name was
::std::_V2::rotate
. The 'Replaces' map does contain '::std::rotate'I don't know this code at all, and from the assert it looks like this is not expected, so I'm afraid I'm not submitting a proper fix.
The text was updated successfully, but these errors were encountered: