[llvm-branch-commits] [clang-tools-extra] release/19.x: [clang-tidy] Fix crash in modernize-use-ranges (#100427) (PR #101482)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 23 05:13:34 PDT 2024


tupos wrote:

Hello,

I think there might be some problem with this PR. I updated to 19.1.0 today and started to see crashes with this callstack on random files. So far I was not able to create a minimal working repro to let it reproducibly crashing.

Strangely enought it does not always crash on the file, from which I obtained the crash. However, maybe you could have an idea what might be wrong.

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x00000000005bde8b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /cpp/llvm-19.1.0/llvm/lib/Support/Unix/Signals.inc:727:3
 #1 0x00000000005bbb94 llvm::sys::RunSignalHandlers() /cpp/llvm-19.1.0/llvm/lib/Support/Signals.cpp:105:20
 #2 0x00000000005bbf4e SignalHandler(int) /cpp/llvm-19.1.0/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007f9844ae2910 __restore_rt (/lib64/libpthread.so.0+0x16910)
 #4 0x0000000000586ee6 llvm::StringMapImpl::LookupBucketFor(llvm::StringRef, unsigned int) /cpp/llvm-19.1.0/llvm/lib/Support/StringMap.cpp:102:25
 #5 0x000000000264755f std::pair<llvm::StringMapIterator<llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>>, bool> llvm::StringMap<llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>, llvm::MallocAllocator>::try_emplace_with_hash<llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>&>(llvm::StringRef, unsigned int, llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>&) /cpp/llvm-19.1.0/llvm/include/llvm/ADT/StringMap.h:376:40
 #6 0x000000000264755f std::pair<llvm::StringMapIterator<llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>>, bool> llvm::StringMap<llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>, llvm::MallocAllocator>::try_emplace<llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>&>(llvm::StringRef, llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>&) /cpp/llvm-19.1.0/llvm/include/llvm/ADT/StringMap.h:369:33
 #7 0x000000000264755f clang::tidy::boost::UseRangesCheck::getReplacerMap() const::'lambda'(llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>, std::initializer_list<llvm::StringRef>, llvm::StringRef)::operator()(llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>, std::initializer_list<llvm::StringRef>, llvm::StringRef) const (.constprop.0) /cpp/llvm-19.1.0/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp:213:30
 #8 0x0000000002647b1d llvm::RefCountedBase<clang::tidy::utils::UseRangesCheck::Replacer>::Release() const /cpp/llvm-19.1.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:102:20
 #9 0x0000000002647b1d llvm::IntrusiveRefCntPtrInfo<clang::tidy::utils::UseRangesCheck::Replacer>::release(clang::tidy::utils::UseRangesCheck::Replacer*) /cpp/llvm-19.1.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:164:45
#10 0x0000000002647b1d llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>::release() /cpp/llvm-19.1.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:233:41
#11 0x0000000002647b1d llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>::~IntrusiveRefCntPtr() /cpp/llvm-19.1.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:196:34
#12 0x0000000002647b1d clang::tidy::boost::UseRangesCheck::getReplacerMap() const::'lambda'(llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>, std::initializer_list<llvm::StringRef>)::operator()(llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>, std::initializer_list<llvm::StringRef>) const (.constprop.0.isra.0) /cpp/llvm-19.1.0/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp:220:16
#13 0x0000000002649032 llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>::release() /cpp/llvm-19.1.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:232:5
#14 0x0000000002649032 llvm::IntrusiveRefCntPtr<clang::tidy::utils::UseRangesCheck::Replacer>::~IntrusiveRefCntPtr() /cpp/llvm-19.1.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:196:34
#15 0x0000000002649032 clang::tidy::boost::UseRangesCheck::getReplacerMap() const /cpp/llvm-19.1.0/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp:234:13
#16 0x0000000002c75a6c clang::tidy::utils::UseRangesCheck::registerMatchers(clang::ast_matchers::MatchFinder*) /cpp/llvm-19.1.0/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp:112:43
#17 0x00000000017a86c8 clang::clangd::ParsedAST::build(llvm::StringRef, clang::clangd::ParseInputs const&, std::unique_ptr<clang::CompilerInvocation, std::default_delete<clang::CompilerInvocation>>, llvm::ArrayRef<clang::clangd::Diag>, std::shared_ptr<clang::clangd::PreambleData const>) /cpp/llvm-19.1.0/clang-tools-extra/clangd/ParsedAST.cpp:565:30
#18 0x0000000001823c30 std::unique_ptr<clang::CompilerInvocation, std::default_delete<clang::CompilerInvocation>>::~unique_ptr() /usr/include/c++/13/bits/unique_ptr.h:403:12
#19 0x0000000001823c30 clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics(std::unique_ptr<clang::CompilerInvocation, std::default_delete<clang::CompilerInvocation>>, clang::clangd::ParseInputs, std::vector<clang::clangd::Diag, std::allocator<clang::clangd::Diag>>) /cpp/llvm-19.1.0/clang-tools-extra/clangd/TUScheduler.cpp:1211:74
#20 0x000000000182465e std::unique_ptr<clang::CompilerInvocation, std::default_delete<clang::CompilerInvocation>>::~unique_ptr() /usr/include/c++/13/bits/unique_ptr.h:403:12
#21 0x000000000182465e clang::clangd::(anonymous namespace)::ASTWorker::updatePreamble(std::unique_ptr<clang::CompilerInvocation, std::default_delete<clang::CompilerInvocation>>, clang::clangd::ParseInputs, std::shared_ptr<clang::clangd::PreambleData const>, std::vector<clang::clangd::Diag, std::allocator<clang::clangd::Diag>>, clang::clangd::WantDiagnostics)::'lambda'()::operator()() (.part.0) /cpp/llvm-19.1.0/clang-tools-extra/clangd/TUScheduler.cpp:1144:24
#22 0x000000000181a273 clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref<void ()>) /cpp/llvm-19.1.0/clang-tools-extra/clangd/TUScheduler.cpp:1325:1
#23 0x000000000181ca16 clang::clangd::(anonymous namespace)::ASTWorker::run() /cpp/llvm-19.1.0/clang-tools-extra/clangd/TUScheduler.cpp:1459:5
#24 0x00000000019c5fc0 llvm::detail::PunnedPointer<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*>>::asInt() const /cpp/llvm-19.1.0/llvm/include/llvm/ADT/PointerIntPair.h:41:16
#25 0x00000000019c5fc0 llvm::detail::PunnedPointer<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*>>::operator long() const /cpp/llvm-19.1.0/llvm/include/llvm/ADT/PointerIntPair.h:45:53
#26 0x00000000019c5fc0 llvm::PointerIntPair<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*>, 1u, bool, llvm::PointerLikeTypeTraits<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*>>, llvm::PointerIntPairInfo<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*>, 1u, llvm::PointerLikeTypeTraits<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*>>>>::getPointer() const /cpp/llvm-19.1.0/llvm/include/llvm/ADT/PointerIntPair.h:94:57
#27 0x00000000019c5fc0 llvm::detail::UniqueFunctionBase<void>::~UniqueFunctionBase() /cpp/llvm-19.1.0/llvm/include/llvm/ADT/FunctionExtras.h:282:42
#28 0x00000000019c5fc0 llvm::detail::UniqueFunctionBase<void>::operator=(llvm::detail::UniqueFunctionBase<void>&&) /cpp/llvm-19.1.0/llvm/include/llvm/ADT/FunctionExtras.h:335:30
#29 0x00000000019c5fc0 llvm::detail::UniqueFunctionBase<void>::operator=(llvm::detail::UniqueFunctionBase<void>&&) /cpp/llvm-19.1.0/llvm/include/llvm/ADT/FunctionExtras.h:328:23
#30 0x00000000019c5fc0 llvm::unique_function<void ()>::operator=(llvm::unique_function<void ()>&&) /cpp/llvm-19.1.0/llvm/include/llvm/ADT/FunctionExtras.h:372:20
#31 0x00000000019c5fc0 operator() /cpp/llvm-19.1.0/clang-tools-extra/clangd/support/Threading.cpp:103:14
#32 0x00000000019c5fc0 operator()<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> /cpp/llvm-19.1.0/llvm/include/llvm/Support/thread.h:43:16
#33 0x00000000019c5fc0 __invoke_impl<void, llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> /usr/include/c++/13/bits/invoke.h:61:36
#34 0x00000000019c5fc0 __invoke<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()>&> /usr/include/c++/13/bits/invoke.h:96:40
#35 0x00000000019c5fc0 __apply_impl<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&, 0> /usr/include/c++/13/tuple:2288:27
#36 0x00000000019c5fc0 apply<llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > >(void*)::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> >&> /usr/include/c++/13/tuple:2299:31
#37 0x00000000019c5fc0 GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function<void()>)::<lambda()> > > /cpp/llvm-19.1.0/llvm/include/llvm/Support/thread.h:41:15
#38 0x00000000019c5fc0 void* llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::'lambda0'()>>(void*) /cpp/llvm-19.1.0/llvm/include/llvm/Support/thread.h:55:36
#39 0x00007f9844ad66ea start_thread (/lib64/libpthread.so.0+0xa6ea)
#40 0x00007f984460f58f clone (/lib64/libc.so.6+0x11858f)
```

https://github.com/llvm/llvm-project/pull/101482


More information about the llvm-branch-commits mailing list