llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.37k stars 12.14k forks source link

Crash: clangd CXXNameMangler::mangleExpression while parsing lambda expression #98572

Open bluecorvetteai opened 4 months ago

bluecorvetteai commented 4 months ago

I pulled the latest from llvm-project main in order to resolve issues fixed in https://github.com/llvm/llvm-project/issues/94614 and https://github.com/llvm/llvm-project/issues/98428.

I built clangd, version:

clangd version 19.0.0git (https://github.com/llvm/llvm-project.git 6c903f05f30147828662eb23f3d91939dbb06a43)
Features: linux+debug
Platform: x86_64-unknown-linux-gnu

No longer see get a crash in clang::TemplateArgument::getNonTypeTemplateArgumentType(), however, I am getting a crash in mangleExpression (or there abouts).

Am I reaching too far? Am I just looking for trouble by pulling from main or is this valuable feedback for the team?

Thanks Kevin

[ERROR][2024-07-11 17:50:41] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/bin/clangd"   "stderr"    "unexpected statement kind"

UNREACHABLE executed at /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:4729!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Stack dump:
0.\t/home/kevin/foo.cpp:422:112: current parser token '{'
1.\t/home/kevin/foo.cpp:15:1: parsing namespace 'abc'
2.\t/home/kevin/foo.cpp:88:1: parsing struct/union/class body 'abc::Foo'
3.\t/home/kevin/foo.cpp:107:53: parsing function body 'abc::Foo::Process'
4.\t/home/kevin/foo.cpp:107:53: in compound statement ('{}')
5.\t/home/kevin/foo.cpp:122:38: in compound statement ('{}')
6.\t/home/kevin/foo.cpp:418:29: lambda expression parsing
"

[ERROR][2024-07-11 17:50:41] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/bin/clangd"   "stderr"    "
 #0 0x0000000001166028 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/kevin/os/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x0000000001164290 llvm::sys::RunSignalHandlers() /home/kevin/os/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00000000011669a8 SignalHandler(int) /home/kevin/os/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007fbc0d638520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fbc0d68c9fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007fbc0d638476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007fbc0d61e7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00000000011110cf (/usr/bin/clangd+0x11110cf)
 #8 0x000000000153615e (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:0:0
 #9 0x0000000001535b6f (anonymous namespace)::CXXNameMangler::mangleMemberExpr(clang::Expr const*, bool, clang::NestedNameSpecifier*, clang::NamedDecl*, clang::DeclarationName, clang::TemplateArgumentLoc const*, unsigned int, unsigned int) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:0:5
#10 0x0000000001535b6f (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:5011:5
#11 0x000000000152e61c (anonymous namespace)::CXXNameMangler::mangleType(clang::DecltypeType const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:4367:3
#12 0x000000000152b050 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) /home/kevin/os/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:0:1
#13 0x000000000152eb59 clang::DependentNameType::getIdentifier() const /home/kevin/os/llvm-project/clang/include/clang/AST/Type.h:6866:12
#14 0x000000000152eb59 (anonymous namespace)::CXXNameMangler::mangleType(clang::DependentNameType const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:4313:23
#15 0x000000000152afd0 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) /home/kevin/os/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:0:1
#16 0x000000000152b080 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) /home/kevin/os/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:0:1
#17 0x0000000001541ff1 (anonymous namespace)::CXXNameMangler::mangleBareFunctionType(clang::FunctionProtoType const*, bool, clang::FunctionDecl const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:3613:5
#18 0x00000000015284dd llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >::~DenseMap() /home/kevin/os/llvm-project/llvm/include/llvm/ADT/DenseMap.h:798:23
#19 0x00000000015284dd (anonymous namespace)::CXXNameMangler::~CXXNameMangler() /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:217:7
#20 0x00000000015284dd (anonymous namespace)::ItaniumMangleContextImpl::mangleLambdaSig(clang::CXXRecordDecl const*, llvm::raw_ostream&) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:7319:1
#21 0x000000000152471d (anonymous namespace)::ItaniumNumberingContext::getManglingNumber(clang::CXXMethodDecl const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumCXXABI.cpp:153:14
#22 0x0000000001c5b05d clang::Sema::handleLambdaNumbering(clang::CXXRecordDecl*, clang::CXXMethodDecl*, std::optional<clang::CXXRecordDecl::LambdaNumbering>) /home/kevin/os/llvm-project/clang/lib/Sema/SemaLambda.cpp:0:38
#23 0x0000000001c5e67f clang::Sema::ActOnStartOfLambdaDefinition(clang::LambdaIntroducer&, clang::Declarator&, clang::DeclSpec const&) /home/kevin/os/llvm-project/clang/lib/Sema/SemaLambda.cpp:0:3
#24 0x000000000331fe05 clang::Token::is(clang::tok::TokenKind) const /home/kevin/os/llvm-project/clang/include/clang/Lex/Token.h:99:49
#25 0x000000000331fe05 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:1615:12
#26 0x000000000331cd5f clang::Parser::ParseLambdaExpression() /home/kevin/os/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:818:10
#27 0x000000000330dde0 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:13
#28 0x00000000033071dc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:20
#29 0x00000000033071dc clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExpr.cpp:182:20
#30 0x0000000003356d0c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/kevin/os/llvm-project/clang/include/clang/Parse/Parser.h:0:14
#31 0x00000000033540da clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:2516:7
#32 0x0000000003353228 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:10
#33 0x0000000003352c79 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:14
#34 0x00000000033a74ea clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:16
#35 0x00000000033a6972 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:121:20
#36 0x00000000033b0732 clang::Parser::ParseCompoundStatementBody(bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1245:11
#37 0x00000000033a7c2b clang::Parser::ParseCompoundStatement(bool, unsigned int) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1039:10
#38 0x00000000033a7c2b clang::Parser::ParseCompoundStatement(bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1004:10
#39 0x00000000033a7c2b clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:305:12
#40 0x00000000033a6972 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:121:20
#41 0x00000000033adbb0 clang::Parser::ParseStatement(clang::SourceLocation*, clang::Parser::ParsedStmtContext) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:49:29
#42 0x00000000033adbb0 clang::Parser::ParseForStatement(clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:2341:19
#43 0x00000000033a7c0f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:12
#44 0x00000000033a6972 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:121:20
#45 0x00000000033b0732 clang::Parser::ParseCompoundStatementBody(bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1245:11
#46 0x00000000033b1922 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:2523:21
#47 0x00000000033d13f0 clang::Token::isNot(clang::tok::TokenKind) const /home/kevin/os/llvm-project/clang/include/clang/Lex/Token.h:100:52
#48 0x00000000033d13f0 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:647:14
#49 0x00000000033d00aa clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:574:33
#50 0x0000000003337321 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3875:21
#51 0x0000000003334ac3 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:0:7
#52 0x0000000003358f7b llvm::SmallVectorBase<unsigned int>::empty() const /home/kevin/os/llvm-project/llvm/include/llvm/ADT/SmallVector.h:94:46
#53 0x0000000003358f7b clang::ParsedAttributesView::empty() const /home/kevin/os/llvm-project/clang/include/clang/Sema/ParsedAttr.h:843:40
#54 0x0000000003358f7b clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:4668:23
#55 0x00000000032e7b59 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:1158:10
#56 0x00000000032e7794 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:1271:12
#57 0x00000000032e6624 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:0:14
#58 0x000000000332ba97 clang::AttributePool::~AttributePool() /home/kevin/os/llvm-project/clang/include/clang/Sema/ParsedAttr.h:726:22
#59 0x000000000332ba97 clang::ParsedAttributes::~ParsedAttributes() /home/kevin/os/llvm-project/clang/include/clang/Sema/ParsedAttr.h:958:7
#60 0x000000000332ba97 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:273:5
#61 0x000000000332b134 clang::Parser::ParseScope::Exit() /home/kevin/os/llvm-project/clang/include/clang/Parse/Parser.h:1197:15
#62 0x000000000332b134 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:252:18
#63 0x0000000003352b6a clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:12
#64 0x00000000032e61df clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:0:0
#65 0x00000000032e473a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:763:10
#66 0x00000000032dfe7e clang::ParseAST(clang::Sema&, bool, bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseAST.cpp:162:5
#67 0x00000000030f4530 clang::FrontendAction::Execute() /home/kevin/os/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1082:10
#68 0x000000000275020d llvm::Error::getPtr() const /home/kevin/os/llvm-project/llvm/include/llvm/Support/Error.h:279:42
#69 0x000000000275020d llvm::Error::operator bool() /home/kevin/os/llvm-project/llvm/include/llvm/Support/Error.h:242:16
#70 0x000000000275020d clang::clangd::BackgroundIndex::index(clang::tooling::CompileCommand) /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/Background.cpp:325:19
#71 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:223:28
#72 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:264:6
#73 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:282:7
#74 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:804:9
#75 0x0000000002752ed8 clang::tooling::CompileCommand::~CompileCommand() /home/kevin/os/llvm-project/clang/include/clang/Tooling/CompilationDatabase.h:44:8
#76 0x0000000002752ed8 clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0::operator()() const /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/Background.cpp:168:22
#77 0x0000000002752ed8 void std::__invoke_impl<void, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&>(std::__invoke_other, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:61:14
#78 0x0000000002752ed8 std::enable_if<is_invocable_r_v<void, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&>, void>::type std::__invoke_r<void, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&>(clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:111:2
#79 0x0000000002752ed8 std::_Function_handler<void (), clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0>::_M_invoke(std::_Any_data const&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/std_function.h:290:9
#80 0x000000000275716a std::_Optional_base_impl<clang::clangd::BackgroundQueue::Task, std::_Optional_base<clang::clangd::BackgroundQueue::Task, false, false> >::_M_is_engaged() const /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:471:58
#81 0x000000000275716a std::_Optional_base_impl<clang::clangd::BackgroundQueue::Task, std::_Optional_base<clang::clangd::BackgroundQueue::Task, false, false> >::_M_get() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:477:2
#82 0x000000000275716a std::optional<clang::clangd::BackgroundQueue::Task>::operator->() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:966:39
#83 0x000000000275716a clang::clangd::BackgroundQueue::work(std::function<void ()>) /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/BackgroundQueue.cpp:44:9
#84 0x0000000002751af8 std::_Function_base::~_Function_base() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/std_function.h:243:11
#85 0x0000000002751af8 clang::clangd::BackgroundIndex::BackgroundIndex(clang::clangd::ThreadsafeFS const&, clang::clangd::GlobalCompilationDatabase const&, llvm::unique_function<clang::clangd::BackgroundIndexStorage* (llvm::StringRef)>, clang::clangd::BackgroundIndex::Options)::$_1::operator()() /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/Background.cpp:114:27
#86 0x0000000002751af8 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)::$_1>(void*) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:220:12
#87 0x00000000027bb8ab llvm::detail::PunnedPointer<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*> >::operator=(long) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:48:5
#88 0x00000000027bb8ab llvm::detail::PunnedPointer<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*> >::PunnedPointer(long) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:37:60
#89 0x00000000027bb8ab 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*> > > >::PointerIntPair() /home/kevin/os/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:86:13
#90 0x00000000027bb8ab llvm::detail::UniqueFunctionBase<void>::UniqueFunctionBase() /home/kevin/os/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:340:3
#91 0x00000000027bb8ab llvm::unique_function<void ()>::unique_function(std::nullptr_t) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:369:3
#92 0x00000000027bb8ab clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1::operator()() /home/kevin/os/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:103:14
#93 0x00000000027bb8ab auto void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...)::operator()<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&>(auto&&, auto&&...) const /home/kevin/os/llvm-project/llvm/include/llvm/Support/thread.h:43:11
#94 0x00000000027bb8ab auto std::__invoke_impl<void, void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&>(std::__invoke_other, void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...)&&, clang:"
[ERROR][2024-07-11 17:50:41] .../vim/lsp/rpc.lua:770    "rpc"   "/usr/bin/clangd"   "stderr"    ":clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:61:14
#95 0x00000000027bb8ab std::__invoke_result<auto, auto...>::type std::__invoke<void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&>(auto&&, auto&&...) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:96:14
#96 0x00000000027bb8ab decltype(auto) std::__apply_impl<void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&, 0ul>(auto&&, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&, std::integer_sequence<unsigned long, 0ul>) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/tuple:2288:14
#97 0x00000000027bb8ab decltype(auto) std::apply<void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&>(auto&&, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/tuple:2299:14
#98 0x00000000027bb8ab void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*) /home/kevin/os/llvm-project/llvm/include/llvm/Support/thread.h:41:5
#99 0x00000000027bb8ab void* llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*) /home/kevin/os/llvm-project/llvm/include/llvm/Support/thread.h:55:5
#100 0x00007fbc0d68aac3 (/lib/x86_64-linux-gnu/libc.so.6+0x94ac3)
#101 0x00007fbc0d71ba04 __clone (/lib/x86_64-linux-gnu/libc.so.6+0x125a04)
llvmbot commented 4 months ago

@llvm/issue-subscribers-clangd

Author: None (bluecorvetteai)

I pulled the latest from llvm-project `main` in order to resolve issues fixed in https://github.com/llvm/llvm-project/issues/94614 and https://github.com/llvm/llvm-project/issues/98428. I built clangd, version: `clangd version 19.0.0git (https://github.com/llvm/llvm-project.git 6c903f05f30147828662eb23f3d91939dbb06a43) Features: linux+debug Platform: x86_64-unknown-linux-gnu` No longer see get a crash in `clang::TemplateArgument::getNonTypeTemplateArgumentType()`, however, I am getting a crash in mangleExpression (or there abouts). Am I reaching too far? Am I just looking for trouble by pulling from `main` or is this valuable feedback for the team? Thanks Kevin [ERROR][2024-07-11 17:50:41] .../vim/lsp/rpc.lua:770 "rpc" "/usr/bin/clangd" "stderr" "unexpected statement kind" UNREACHABLE executed at /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:4729! PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0.\t/home/kevin/foo.cpp:422:112: current parser token '{' 1.\t/home/kevin/foo.cpp:15:1: parsing namespace 'abc' 2.\t/home/kevin/foo.cpp:88:1: parsing struct/union/class body 'abc::Foo' 3.\t/home/kevin/foo.cpp:107:53: parsing function body 'abc::Foo::Process' 4.\t/home/kevin/foo.cpp:107:53: in compound statement ('{}') 5.\t/home/kevin/foo.cpp:122:38: in compound statement ('{}') 6.\t/home/kevin/foo.cpp:418:29: lambda expression parsing " [ERROR][2024-07-11 17:50:41] .../vim/lsp/rpc.lua:770 "rpc" "/usr/bin/clangd" "stderr" " #0 0x0000000001166028 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/kevin/os/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13 #1 0x0000000001164290 llvm::sys::RunSignalHandlers() /home/kevin/os/llvm-project/llvm/lib/Support/Signals.cpp:106:18 #2 0x00000000011669a8 SignalHandler(int) /home/kevin/os/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1 #3 0x00007fbc0d638520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x00007fbc0d68c9fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc) #5 0x00007fbc0d638476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476) #6 0x00007fbc0d61e7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3) #7 0x00000000011110cf (/usr/bin/clangd+0x11110cf) #8 0x000000000153615e (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:0:0 #9 0x0000000001535b6f (anonymous namespace)::CXXNameMangler::mangleMemberExpr(clang::Expr const*, bool, clang::NestedNameSpecifier*, clang::NamedDecl*, clang::DeclarationName, clang::TemplateArgumentLoc const*, unsigned int, unsigned int) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:0:5 #10 0x0000000001535b6f (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:5011:5 #11 0x000000000152e61c (anonymous namespace)::CXXNameMangler::mangleType(clang::DecltypeType const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:4367:3 #12 0x000000000152b050 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) /home/kevin/os/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:0:1 #13 0x000000000152eb59 clang::DependentNameType::getIdentifier() const /home/kevin/os/llvm-project/clang/include/clang/AST/Type.h:6866:12 #14 0x000000000152eb59 (anonymous namespace)::CXXNameMangler::mangleType(clang::DependentNameType const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:4313:23 #15 0x000000000152afd0 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) /home/kevin/os/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:0:1 #16 0x000000000152b080 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) /home/kevin/os/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:0:1 #17 0x0000000001541ff1 (anonymous namespace)::CXXNameMangler::mangleBareFunctionType(clang::FunctionProtoType const*, bool, clang::FunctionDecl const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:3613:5 #18 0x00000000015284dd llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int> >::~DenseMap() /home/kevin/os/llvm-project/llvm/include/llvm/ADT/DenseMap.h:798:23 #19 0x00000000015284dd (anonymous namespace)::CXXNameMangler::~CXXNameMangler() /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:217:7 #20 0x00000000015284dd (anonymous namespace)::ItaniumMangleContextImpl::mangleLambdaSig(clang::CXXRecordDecl const*, llvm::raw_ostream&) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumMangle.cpp:7319:1 #21 0x000000000152471d (anonymous namespace)::ItaniumNumberingContext::getManglingNumber(clang::CXXMethodDecl const*) /home/kevin/os/llvm-project/clang/lib/AST/ItaniumCXXABI.cpp:153:14 #22 0x0000000001c5b05d clang::Sema::handleLambdaNumbering(clang::CXXRecordDecl*, clang::CXXMethodDecl*, std::optional<clang::CXXRecordDecl::LambdaNumbering>) /home/kevin/os/llvm-project/clang/lib/Sema/SemaLambda.cpp:0:38 #23 0x0000000001c5e67f clang::Sema::ActOnStartOfLambdaDefinition(clang::LambdaIntroducer&, clang::Declarator&, clang::DeclSpec const&) /home/kevin/os/llvm-project/clang/lib/Sema/SemaLambda.cpp:0:3 #24 0x000000000331fe05 clang::Token::is(clang::tok::TokenKind) const /home/kevin/os/llvm-project/clang/include/clang/Lex/Token.h:99:49 #25 0x000000000331fe05 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:1615:12 #26 0x000000000331cd5f clang::Parser::ParseLambdaExpression() /home/kevin/os/llvm-project/clang/lib/Parse/ParseExprCXX.cpp:818:10 #27 0x000000000330dde0 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:13 #28 0x00000000033071dc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:20 #29 0x00000000033071dc clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/kevin/os/llvm-project/clang/lib/Parse/ParseExpr.cpp:182:20 #30 0x0000000003356d0c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/kevin/os/llvm-project/clang/include/clang/Parse/Parser.h:0:14 #31 0x00000000033540da clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:2516:7 #32 0x0000000003353228 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:10 #33 0x0000000003352c79 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:14 #34 0x00000000033a74ea clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:16 #35 0x00000000033a6972 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:121:20 #36 0x00000000033b0732 clang::Parser::ParseCompoundStatementBody(bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1245:11 #37 0x00000000033a7c2b clang::Parser::ParseCompoundStatement(bool, unsigned int) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1039:10 #38 0x00000000033a7c2b clang::Parser::ParseCompoundStatement(bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1004:10 #39 0x00000000033a7c2b clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:305:12 #40 0x00000000033a6972 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:121:20 #41 0x00000000033adbb0 clang::Parser::ParseStatement(clang::SourceLocation*, clang::Parser::ParsedStmtContext) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:49:29 #42 0x00000000033adbb0 clang::Parser::ParseForStatement(clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:2341:19 #43 0x00000000033a7c0f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:12 #44 0x00000000033a6972 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:121:20 #45 0x00000000033b0732 clang::Parser::ParseCompoundStatementBody(bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:1245:11 #46 0x00000000033b1922 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseStmt.cpp:2523:21 #47 0x00000000033d13f0 clang::Token::isNot(clang::tok::TokenKind) const /home/kevin/os/llvm-project/clang/include/clang/Lex/Token.h:100:52 #48 0x00000000033d13f0 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:647:14 #49 0x00000000033d00aa clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:574:33 #50 0x0000000003337321 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:3875:21 #51 0x0000000003334ac3 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:0:7 #52 0x0000000003358f7b llvm::SmallVectorBase<unsigned int>::empty() const /home/kevin/os/llvm-project/llvm/include/llvm/ADT/SmallVector.h:94:46 #53 0x0000000003358f7b clang::ParsedAttributesView::empty() const /home/kevin/os/llvm-project/clang/include/clang/Sema/ParsedAttr.h:843:40 #54 0x0000000003358f7b clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:4668:23 #55 0x00000000032e7b59 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:1158:10 #56 0x00000000032e7794 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:1271:12 #57 0x00000000032e6624 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:0:14 #58 0x000000000332ba97 clang::AttributePool::~AttributePool() /home/kevin/os/llvm-project/clang/include/clang/Sema/ParsedAttr.h:726:22 #59 0x000000000332ba97 clang::ParsedAttributes::~ParsedAttributes() /home/kevin/os/llvm-project/clang/include/clang/Sema/ParsedAttr.h:958:7 #60 0x000000000332ba97 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:273:5 #61 0x000000000332b134 clang::Parser::ParseScope::Exit() /home/kevin/os/llvm-project/clang/include/clang/Parse/Parser.h:1197:15 #62 0x000000000332b134 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:252:18 #63 0x0000000003352b6a clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) /home/kevin/os/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:12 #64 0x00000000032e61df clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:0:0 #65 0x00000000032e473a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/kevin/os/llvm-project/clang/lib/Parse/Parser.cpp:763:10 #66 0x00000000032dfe7e clang::ParseAST(clang::Sema&, bool, bool) /home/kevin/os/llvm-project/clang/lib/Parse/ParseAST.cpp:162:5 #67 0x00000000030f4530 clang::FrontendAction::Execute() /home/kevin/os/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1082:10 #68 0x000000000275020d llvm::Error::getPtr() const /home/kevin/os/llvm-project/llvm/include/llvm/Support/Error.h:279:42 #69 0x000000000275020d llvm::Error::operator bool() /home/kevin/os/llvm-project/llvm/include/llvm/Support/Error.h:242:16 #70 0x000000000275020d clang::clangd::BackgroundIndex::index(clang::tooling::CompileCommand) /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/Background.cpp:325:19 #71 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:223:28 #72 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:264:6 #73 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:282:7 #74 0x0000000002752ed8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/basic_string.h:804:9 #75 0x0000000002752ed8 clang::tooling::CompileCommand::~CompileCommand() /home/kevin/os/llvm-project/clang/include/clang/Tooling/CompilationDatabase.h:44:8 #76 0x0000000002752ed8 clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0::operator()() const /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/Background.cpp:168:22 #77 0x0000000002752ed8 void std::__invoke_impl<void, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&>(std::__invoke_other, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:61:14 #78 0x0000000002752ed8 std::enable_if<is_invocable_r_v<void, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&>, void>::type std::__invoke_r<void, clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&>(clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:111:2 #79 0x0000000002752ed8 std::_Function_handler<void (), clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::$_0>::_M_invoke(std::_Any_data const&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/std_function.h:290:9 #80 0x000000000275716a std::_Optional_base_impl<clang::clangd::BackgroundQueue::Task, std::_Optional_base<clang::clangd::BackgroundQueue::Task, false, false> >::_M_is_engaged() const /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:471:58 #81 0x000000000275716a std::_Optional_base_impl<clang::clangd::BackgroundQueue::Task, std::_Optional_base<clang::clangd::BackgroundQueue::Task, false, false> >::_M_get() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:477:2 #82 0x000000000275716a std::optional<clang::clangd::BackgroundQueue::Task>::operator->() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/optional:966:39 #83 0x000000000275716a clang::clangd::BackgroundQueue::work(std::function<void ()>) /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/BackgroundQueue.cpp:44:9 #84 0x0000000002751af8 std::_Function_base::~_Function_base() /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/std_function.h:243:11 #85 0x0000000002751af8 clang::clangd::BackgroundIndex::BackgroundIndex(clang::clangd::ThreadsafeFS const&, clang::clangd::GlobalCompilationDatabase const&, llvm::unique_function<clang::clangd::BackgroundIndexStorage* (llvm::StringRef)>, clang::clangd::BackgroundIndex::Options)::$_1::operator()() /home/kevin/os/llvm-project/clang-tools-extra/clangd/index/Background.cpp:114:27 #86 0x0000000002751af8 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)::$_1>(void*) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:220:12 #87 0x00000000027bb8ab llvm::detail::PunnedPointer<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*> >::operator=(long) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:48:5 #88 0x00000000027bb8ab llvm::detail::PunnedPointer<llvm::PointerUnion<llvm::detail::UniqueFunctionBase<void>::TrivialCallback*, llvm::detail::UniqueFunctionBase<void>::NonTrivialCallbacks*> >::PunnedPointer(long) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:37:60 #89 0x00000000027bb8ab 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*> > > >::PointerIntPair() /home/kevin/os/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:86:13 #90 0x00000000027bb8ab llvm::detail::UniqueFunctionBase<void>::UniqueFunctionBase() /home/kevin/os/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:340:3 #91 0x00000000027bb8ab llvm::unique_function<void ()>::unique_function(std::nullptr_t) /home/kevin/os/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:369:3 #92 0x00000000027bb8ab clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1::operator()() /home/kevin/os/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:103:14 #93 0x00000000027bb8ab auto void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...)::operator()<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&>(auto&&, auto&&...) const /home/kevin/os/llvm-project/llvm/include/llvm/Support/thread.h:43:11 #94 0x00000000027bb8ab auto std::__invoke_impl<void, void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&>(std::__invoke_other, void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...)&&, clang:" [ERROR][2024-07-11 17:50:41] .../vim/lsp/rpc.lua:770 "rpc" "/usr/bin/clangd" "stderr" ":clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:61:14 #95 0x00000000027bb8ab std::__invoke_result<auto, auto...>::type std::__invoke<void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1&>(auto&&, auto&&...) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/invoke.h:96:14 #96 0x00000000027bb8ab decltype(auto) std::__apply_impl<void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&, 0ul>(auto&&, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&, std::integer_sequence<unsigned long, 0ul>) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/tuple:2288:14 #97 0x00000000027bb8ab decltype(auto) std::apply<void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*)::'lambda'(auto&&, auto&&...), std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&>(auto&&, std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>&) /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/tuple:2299:14 #98 0x00000000027bb8ab void llvm::thread::GenericThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*) /home/kevin/os/llvm-project/llvm/include/llvm/Support/thread.h:41:5 #99 0x00000000027bb8ab void* llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1> >(void*) /home/kevin/os/llvm-project/llvm/include/llvm/Support/thread.h:55:5 #100 0x00007fbc0d68aac3 (/lib/x86_64-linux-gnu/libc.so.6+0x94ac3) #101 0x00007fbc0d71ba04 __clone (/lib/x86_64-linux-gnu/libc.so.6+0x125a04)
EugeneZelenko commented 4 months ago

@bluecorvetteai: Does standalone Clang crash?

bluecorvetteai commented 4 months ago

@EugeneZelenko No, it builds.

HighCommander4 commented 4 months ago

Am I reaching too far? Am I just looking for trouble by pulling from main or is this valuable feedback for the team?

It's definitely useful to get reports of crashes with trunk.

If you're able to prepare a test case that reproduces the crash, that would be very helpful for further investigation.

bluecorvetteai commented 4 months ago

I figured an example would be helpful. Kind of under the gun at the moment, but I'll spend some time on it, I would like to help.

bluecorvetteai commented 4 months ago

The code that prompted this bug report was pretty complicated. However, after commenting it out, I found another that was very simple. A very simple lambda being passed to sort blew it up. Also the more complicated example, it appears to be either the capture or the parameter list that clangd is choking on.

Coming up with an example doesn't seem as daunting now. Give me a bit to put a project together to see if I can't get some meat to chew on.

bluecorvetteai commented 4 months ago

@HighCommander4 I keep coming up empty when trying to reproduce this.

It isn't all lambdas that trigger the crash. It can parse a number of them before it finally crashes. The offending lambda appears it has to be part of a very large function with other lambdas before it (this lambda is pretty simple) in order to trigger a crash. I've included statement that is triggering in our regular code below. If I comment out the call to std::sort with the accompanying lambda, it doesn't crash.

This appears to be the proverbial straw that breaks the camel's back.

If you have any ideas, I'm all ears. Otherwise, I'll keep thinking about this and keep trying.

    std::vector<std::pair<int64_t, int64_t>> ids = {{1,2},{3,4},{5,6},{7,8}};
    std::vector<std::pair<int64_t, int64_t>> sorted_ids;
    sorted_ids.reserve(ids.size());
    for( auto& r : ids ){
      sorted_ids.emplace_back(r.first, r.second);
    }
    std::sort(sorted_ids.begin(), sorted_ids.end(),
              [](const decltype(sorted_ids)::value_type& a,
                 const decltype(sorted_ids)::value_type& b) {
                return a.second < b.second;
              });
HighCommander4 commented 4 months ago

The approach I usually take to reduce crashing testcases is to start with the full translation unit, and progressively remove things (statements, declarations, includes) that can be removed while preserving the crashing behaviour.

You might find it convenient to trigger the crash on the command line using clangd --check=filename.cpp rather than in an editor.

bluecorvetteai commented 4 months ago

Perfect, I did not know about --check, that will speed things up, thank you.

zyn0217 commented 5 days ago

@bluecorvetteai Is everything working fine with the trunk right now, or has there been any progress with the reduced code? thanks