[llvm-bugs] [Bug 52203] New: clangd 13.0 crashes with the simplest C++ code

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 18 01:57:59 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52203

            Bug ID: 52203
           Summary: clangd 13.0 crashes with the simplest C++ code
           Product: clang-tools-extra
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: clangd
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 312988336 at qq.com
                CC: llvm-bugs at lists.llvm.org

The following simplest code is sure to cause clangd to crash repeatedly in
vscode LSP mode.

#include <range/v3/all.hpp>

int main()
{
    auto il = {1, 2, 3};
    ranges::subrange(il.begin(), il.end()); // This line is the culprit!
}

--- error message ---

I[18:10:42.018] <-- textDocument/semanticTokens/full(3)
V[18:11:00.537] indexed preamble AST for /data/lyx/utl/main.cpp version 1:
  symbol slab: 22283 symbols, 5923440 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 1217 relations, 34840 bytes
V[18:11:01.099] Build dynamic index for header symbols with estimated memory
usage of 12107732 bytes
V[18:11:01.132] Built preamble of size 18693284 for file /data/lyx/utl/main.cpp
version 1
I[18:11:01.139] --> workspace/semanticTokens/refresh(0)
I[18:11:01.139] --> textDocument/clangd.fileStatus
V[18:11:01.139] >>> {
  "id": 0,
  "jsonrpc": "2.0",
  "method": "workspace/semanticTokens/refresh",
  "params": null
}

V[18:11:01.139] >>> {
  "jsonrpc": "2.0",
  "method": "textDocument/clangd.fileStatus",
  "params": {
    "state": "parsing includes, running Build AST for (1)",
    "uri": "file:///data/lyx/utl/main.cpp"
  }
}

V[18:11:01.140] <<< {
  "id": 0,
  "jsonrpc": "2.0",
  "result": null
}

I[18:11:01.140] <-- reply(0)
clangd:
/data/tmp/llvm-13.0/src/llvm/tools/clang/include/clang/AST/DeclTemplate.h:375:
void clang::DefaultArgStorage<clang::TemplateTypeParmDecl,
clang::TypeSourceInfo *>::setInherited(const clang::ASTContext &, ParmDecl *)
[ParmDecl = clang::TemplateTypeParmDecl, ArgType = clang::TypeSourceInfo *]:
Assertion `!isInherited() && "default argument already inherited"' failed.
 #0 0x00000000008aafca llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/usr/local/bin/clangd+0x8aafca)
 #1 0x00000000008ab1ab PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #2 0x00000000008a914b llvm::sys::RunSignalHandlers()
(/usr/local/bin/clangd+0x8a914b)
 #3 0x00000000008abb91 SignalHandler(int) Signals.cpp:0:0
 #4 0x00007efe0e4183c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x00007efe0de7618b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007efe0de55859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #7 0x00007efe0de55729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
 #8 0x00007efe0de55729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
 #9 0x00007efe0de66f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#10 0x000000000301857f clang::DefaultArgStorage<clang::TemplateTypeParmDecl,
clang::TypeSourceInfo*>::setInherited(clang::ASTContext const&,
clang::TemplateTypeParmDecl*) (/usr/local/bin/clangd+0x301857f)
#11 0x00000000030184fe
clang::TemplateTypeParmDecl::setInheritedDefaultArgument(clang::ASTContext
const&, clang::TemplateTypeParmDecl*) (/usr/local/bin/clangd+0x30184fe)
#12 0x00000000030183fc bool
inheritDefaultTemplateArgument<clang::TemplateTypeParmDecl>(clang::ASTContext&,
clang::TemplateTypeParmDecl*, clang::Decl*) ASTReaderDecl.cpp:0:0
#13 0x000000000300c5ae inheritDefaultTemplateArguments(clang::ASTContext&,
clang::TemplateDecl*, clang::TemplateDecl*) ASTReaderDecl.cpp:0:0
#14 0x000000000300c12c
clang::ASTDeclReader::attachPreviousDecl(clang::ASTReader&, clang::Decl*,
clang::Decl*, clang::Decl*) (/usr/local/bin/clangd+0x300c12c)
#15 0x00000000030129d0 clang::ASTReader::loadPendingDeclChain(clang::Decl*,
unsigned long) (/usr/local/bin/clangd+0x30129d0)
#16 0x0000000002f4cdb4 clang::ASTReader::finishPendingActions()
(/usr/local/bin/clangd+0x2f4cdb4)
#17 0x0000000002f5f713 clang::ASTReader::FinishedDeserializing()
(/usr/local/bin/clangd+0x2f5f713)
#18 0x0000000000a56f7f
clang::ExternalASTSource::Deserializing::~Deserializing()
(/usr/local/bin/clangd+0xa56f7f)
#19 0x0000000002f41b67
clang::ASTReader::FindExternalVisibleDeclsByName(clang::DeclContext const*,
clang::DeclarationName) (/usr/local/bin/clangd+0x2f41b67)
#20 0x0000000000a7dce8 clang::DeclContext::lookup(clang::DeclarationName) const
(/usr/local/bin/clangd+0xa7dce8)
#21 0x0000000000a7dace clang::DeclContext::lookup(clang::DeclarationName) const
(/usr/local/bin/clangd+0xa7dace)
#22 0x0000000003d9d3cc
clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*,
clang::SourceLocation) (/usr/local/bin/clangd+0x3d9d3cc)
#23 0x0000000003a985d7 DeclareImplicitMemberFunctionsWithName(clang::Sema&,
clang::DeclarationName, clang::SourceLocation, clang::DeclContext const*)
SemaLookup.cpp:0:0
#24 0x0000000003a9b7d3 LookupDirect(clang::Sema&, clang::LookupResult&,
clang::DeclContext const*) SemaLookup.cpp:0:0
#25 0x0000000003a98cd8 clang::Sema::LookupQualifiedName(clang::LookupResult&,
clang::DeclContext*, bool) (/usr/local/bin/clangd+0x3a98cd8)
#26 0x0000000003a4e3dc
clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>) (/usr/local/bin/clangd+0x3a4e3dc)
#27 0x00000000038b524e
clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, bool) (/usr/local/bin/clangd+0x38b524e)
#28 0x00000000038b4e35
clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr<clang::QualType>,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, bool) (/usr/local/bin/clangd+0x38b4e35)
#29 0x0000000002e757e4
clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&)
(/usr/local/bin/clangd+0x2e757e4)
#30 0x0000000002e5cc74
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*) (/usr/local/bin/clangd+0x2e5cc74)
#31 0x0000000002e550a4
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*) (/usr/local/bin/clangd+0x2e550a4)
#32 0x0000000002e53448
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/usr/local/bin/clangd+0x2e53448)
#33 0x0000000002e532e2
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/usr/local/bin/clangd+0x2e532e2)
#34 0x0000000002ed8db4
clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext)
(/usr/local/bin/clangd+0x2ed8db4)
#35 0x0000000002ed77d9
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::ParsedAttributesWithRange&) (/usr/local/bin/clangd+0x2ed77d9)
#36 0x0000000002ed70f9
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/usr/local/bin/clangd+0x2ed70f9)
#37 0x0000000002edf88c clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/bin/clangd+0x2edf88c)
#38 0x0000000002ee115b clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/bin/clangd+0x2ee115b)
#39 0x0000000002dec5b6
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/local/bin/clangd+0x2dec5b6)
#40 0x0000000002e1189d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/bin/clangd+0x2e1189d)
#41 0x0000000002deafb7
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/bin/clangd+0x2deafb7)
#42 0x0000000002dea4d0
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/bin/clangd+0x2dea4d0)
#43 0x0000000002de9adf
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/bin/clangd+0x2de9adf)
#44 0x0000000002de7ab1
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/usr/local/bin/clangd+0x2de7ab1)
#45 0x0000000002de7303
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/bin/clangd+0x2de7303)
#46 0x0000000002de1dce clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/bin/clangd+0x2de1dce)
#47 0x0000000002c21a62 clang::ASTFrontendAction::ExecuteAction()
(/usr/local/bin/clangd+0x2c21a62)
#48 0x0000000002c21198 clang::FrontendAction::Execute()
(/usr/local/bin/clangd+0x2c21198)
#49 0x000000000176cdb2 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>)
(/usr/local/bin/clangd+0x176cdb2)
#50 0x00000000018e8181 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> >)
TUScheduler.cpp:0:0
#51 0x00000000018e7aaa 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)::$_2::operator()() TUScheduler.cpp:0:0
#52 0x00000000018ebeed void
llvm::detail::UniqueFunctionBase<void>::CallImpl<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[Error - 6:11:03 PM] Connection
to server got closed. Server will not be restarted.
[Error - 6:11:03 PM] Request textDocument/documentSymbol failed.
[object Object]
[Error - 6:11:03 PM] Request textDocument/codeAction failed.
[object Object]
[Error - 6:11:03 PM] Request textDocument/semanticTokens/full failed.
[object Object]

Please attach the clangd stderr log if you can. (Usually available from the
editor)
If possible, run with --log=verbose - note that the logs will include the
contents of open files!
If this is a crash, try to put llvm-symbolizer on your PATH per the
troubleshooting instructions.

System information

Output of clangd --version:

clangd version 13.0.0
Features: linux+debug
Platform: x86_64-unknown-linux-gnu
Editor/LSP plugin: vscode 16.1

Operating system: Ubuntu 20.04

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211018/d18af45b/attachment-0001.html>


More information about the llvm-bugs mailing list