Skip to content

clang-tidy: Crash with performance-unnecessary-value-param #108963

@VReichelt

Description

@VReichelt

Running clang-tidy -checks="-*,performance-unnecessary-value-param" on the following valid code

struct A
{
  template<typename T> A(T&&) {}
};

struct B
{
  ~B();
};

struct C
{
  A a;
  C(B, int i) : a(i) {}
};

C c(B(), 0);

triggers an assertion

clang-tidy: /tmp/LLVM/llvm-project/llvm/include/llvm/ADT/DenseMap.h:1238: llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type* llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::operator->() const [with KeyT = const clang::FunctionDecl*; ValueT = std::unique_ptr<clang::FunctionParmMutationAnalyzer>; KeyInfoT = llvm::DenseMapInfo<const clang::FunctionDecl*, void>; Bucket = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >; bool IsConst = false; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::pointer = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >*; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >]: Assertion `isHandleInSync() && "invalid iterator access!"' failed.

This is a very recent regression on trunk. It worked fine a week ago with revision 1c334de and failed with revision f710612 .

Full stacktrace:

clang-tidy: /tmp/LLVM/llvm-project/llvm/include/llvm/ADT/DenseMap.h:1238: llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type* llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::operator->() const [with KeyT = const clang::FunctionDecl*; ValueT = std::unique_ptr<clang::FunctionParmMutationAnalyzer>; KeyInfoT = llvm::DenseMapInfo<const clang::FunctionDecl*, void>; Bucket = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >; bool IsConst = false; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::pointer = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >*; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type = llvm::detail::DenseMapPair<const clang::FunctionDecl*, std::unique_ptr<clang::FunctionParmMutationAnalyzer> >]: Assertion `isHandleInSync() && "invalid iterator access!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: LLVM/bin/clang-tidy -checks=-*,performance-unnecessary-value-param CTbug.cc
1.	<eof> parser at end of file
2.	ASTMatcher: Processing 'performance-unnecessary-value-param' against:
	CXXConstructorDecl C::C : <CTbug.cc:14:3, col:23>
--- Bound Nodes Begin ---
    functionDecl - { CXXConstructorDecl C::C : <CTbug.cc:14:3, col:23> }
    param - { ParmVarDecl  : <CTbug.cc:14:5> }
--- Bound Nodes End ---
 #0 0x000000000475c248 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (LLVM/bin/clang-tidy+0x475c248)
 #1 0x000000000475999c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f2de91dbce0 __restore_rt (/lib64/libpthread.so.0+0x12ce0)
 #3 0x00007f2de7c5aa9f raise (/lib64/libc.so.6+0x4ea9f)
 #4 0x00007f2de7c2de05 abort (/lib64/libc.so.6+0x21e05)
 #5 0x00007f2de7c2dcd9 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21cd9)
 #6 0x00007f2de7c533f6 (/lib64/libc.so.6+0x473f6)
 #7 0x00000000010b8192 clang::tidy::performance::UnnecessaryValueParamCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (LLVM/bin/clang-tidy+0x10b8192)
 #8 0x00000000032bdbd9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) ASTMatchFinder.cpp:0:0
 #9 0x0000000003304427 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (LLVM/bin/clang-tidy+0x3304427)
#10 0x00000000032c0174 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) ASTMatchFinder.cpp:0:0
#11 0x00000000032e409e clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#12 0x00000000032e4aea clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.9962) ASTMatchFinder.cpp:0:0
#13 0x00000000032f7eea clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseCXXRecordDecl(clang::CXXRecordDecl*) ASTMatchFinder.cpp:0:0
#14 0x00000000032e363d clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#15 0x00000000032e40a9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#16 0x00000000032e4aea clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.9962) ASTMatchFinder.cpp:0:0
#17 0x00000000032f7705 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) ASTMatchFinder.cpp:0:0
#18 0x00000000032e39bf clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#19 0x00000000032e40a9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) ASTMatchFinder.cpp:0:0
#20 0x00000000032e43a1 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (LLVM/bin/clang-tidy+0x32e43a1)
#21 0x00000000020bab18 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (LLVM/bin/clang-tidy+0x20bab18)
#22 0x0000000002319e2c clang::ParseAST(clang::Sema&, bool, bool) (LLVM/bin/clang-tidy+0x2319e2c)
#23 0x0000000002084ab9 clang::FrontendAction::Execute() (LLVM/bin/clang-tidy+0x2084ab9)
#24 0x000000000200bf29 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (LLVM/bin/clang-tidy+0x200bf29)
#25 0x00000000018bc0b9 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (LLVM/bin/clang-tidy+0x18bc0b9)
#26 0x000000000186915e 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
#27 0x00000000018b6e5b clang::tooling::ToolInvocation::run() (LLVM/bin/clang-tidy+0x18b6e5b)
#28 0x00000000018b996d clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (LLVM/bin/clang-tidy+0x18b996d)
#29 0x00000000018755a9 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) (LLVM/bin/clang-tidy+0x18755a9)
#30 0x0000000000aefca2 clang::tidy::clangTidyMain(int, char const**) (LLVM/bin/clang-tidy+0xaefca2)
#31 0x00007f2de7c46cf3 __libc_start_main (/lib64/libc.so.6+0x3acf3)
#32 0x0000000000ae595e _start (LLVM/bin/clang-tidy+0xae595e)
bin/TidyTest: line 1: 4173665 Aborted                 (core dumped) LLVM/bin/clang-tidy -checks="-*,performance-unnecessary-value-param" $1

Metadata

Metadata

Labels

clang:analysiscrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions