Skip to content

clangd crashes in DeclareAggregateDeductionGuideFromInitList() #112953

@schenker

Description

@schenker

This problem occurs with both clangd 19.1.0 and f3c408d.

My project contains .cpp files that include .hpp files that are generated during the build. The .cpp files are present from the beginning. I was only able to reproduce this crash while the generated .hpp were still missing. With all the generated header present, I was not able to reproduce the problem.

The range-v3 library from the error message below is this one: https://github.com/ericniebler/range-v3/archive/refs/tags/0.12.0.tar.gz.
I can unfortunately not provide more sources.

I[18:42:55.200] clangd version 20.0.0git (https://github.com/llvm/llvm-project.git f3c408d1726f6a921212faf68085f68bf8533f0c)
I[18:42:55.200] Features: linux
I[18:42:55.200] argv[0]: /home/myuser/workspace/llvm-project-build/install/bin/clangd
I[18:42:55.200] argv[1]: --background-index
I[18:42:55.200] argv[2]: --header-insertion=never
I[18:42:55.200] argv[3]: --cross-file-rename
I[18:42:55.200] argv[4]: --clang-tidy
I[18:42:55.200] argv[5]: --all-scopes-completion
I[18:42:55.200] argv[6]: -j=16
I[18:42:55.200] argv[7]: --log=verbose
...
V[18:56:47.531] Build dynamic index for header symbols with estimated memory usage of 47815514 bytes
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:117:44: current parser token ';'
1.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:47:1: parsing namespace 'ranges'
2.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:106:5 <Spelling=/home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/detail/config.hpp:630:5>: parsing struct/union/class body 'ranges::nth_element_fn'
3.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:113:9: parsing function body 'ranges::nth_element_fn::operator()'
4.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:113:9: in compound statement ('{}')
 #0 0x0000564a101b41ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x7941ff)
 #1 0x0000564a101b1cb4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f1d52307420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x0000564a10b77ee4 clang::Sema::DeclareAggregateDeductionGuideFromInitList(clang::TemplateDecl*, llvm::MutableArrayRef<clang::QualType>, clang::SourceLocation) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x1157ee4)
 #4 0x0000564a113ce766 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>)::'lambda0'(bool)::operator()(bool) const::'lambda'(clang::InitListExpr*)::operator()(clang::InitListExpr*) const SemaInit.cpp:0:0
 #5 0x0000564a113cef77 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>)::'lambda0'(bool)::operator()(bool) const SemaInit.cpp:0:0
 #6 0x0000564a113cfa22 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x19afa22)
 #7 0x0000564a10f52e20 clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x1532e20)
 #8 0x0000564a10f5fabf clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x153fabf)
 #9 0x0000564a10f84d39 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x1564d39)
#10 0x0000564a138a5d9c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e85d9c)
#11 0x0000564a138bb941 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9b941)
#12 0x0000564a138be500 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9e500)
#13 0x0000564a138bea47 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9ea47)
#14 0x0000564a139720fc clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f520fc)
#15 0x0000564a13972ad4 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f52ad4)
#16 0x0000564a13973e39 clang::Parser::ParseCompoundStatementBody(bool) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f53e39)
#17 0x0000564a13976162 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f56162)
#18 0x0000564a1388b1ee clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e6b1ee)
#19 0x0000564a1388ae7d clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e6ae7d)
#20 0x0000564a138e0bb6 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3ec0bb6)
#21 0x0000564a138e3aa8 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3ec3aa8)
#22 0x0000564a138ac619 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e8c619)
#23 0x0000564a138732ef clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e532ef)
#24 0x0000564a13874200 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e54200)
#25 0x0000564a1387ddc3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e5ddc3)
#26 0x0000564a138d9c57 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3eb9c57)
#27 0x0000564a138e2047 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3ec2047)
#28 0x0000564a138bec25 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9ec25)
#29 0x0000564a1387de74 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e5de74)
#30 0x0000564a1387f6f8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e5f6f8)
#31 0x0000564a1386d94a clang::ParseAST(clang::Sema&, bool, bool) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e4d94a)
#32 0x0000564a135e4891 clang::FrontendAction::Execute() (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3bc4891)
#33 0x0000564a11b97cd0 clang::clangd::BackgroundIndex::index(clang::tooling::CompileCommand) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x2177cd0)
#34 0x0000564a11b9914d clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)::'lambda'()::operator()() const Background.cpp:0:0
#35 0x0000564a11ba459f clang::clangd::BackgroundQueue::work(std::function<void ()>) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x218459f)
#36 0x0000564a11b90d8d void llvm::detail::UniqueFunctionBase<void>::CallImpl<clang::clangd::BackgroundIndex::BackgroundIndex(clang::clangd::ThreadsafeFS const&, clang::clangd::GlobalCompilationDatabase const&, llvm::unique_function<clang::clangd::BackgroundIndexStorage* (llvm::StringRef)>, clang::clangd::BackgroundIndex::Options)::'lambda0'()>(void*) Background.cpp:0:0
#37 0x0000564a11c4ce16 void* llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::'lambda0'()>>(void*) Threading.cpp:0:0
#38 0x00007f1d522fb609 start_thread /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:478:7
#39 0x00007f1d51e07353 __clone /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97:0
[Error - 6:56:50 PM] The Clang Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions