llvm / llvm-project

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

clangd crashes when deducing template arguments #113518

Open szmarczak opened 3 days ago

szmarczak commented 3 days ago
#include <array>
#include <iostream>

template<typename T>
struct ArrayType {
    template<size_t size>
    using Array = std::array<T, size>;
};

template<ArrayType<int>::Array array>
void test() {
    for (const auto& item : array) {
        std::cout << item << std::endl;
    }
}

void foo() {
    test<{1,2,3}>();
}
It crashes clangd. ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. /home/openvscode-server/latte/source/bug.hpp:18:19: current parser token ')' 1. /home/openvscode-server/latte/source/bug.hpp:17:12: parsing function body 'foo' 2. /home/openvscode-server/latte/source/bug.hpp:17:12: in compound statement ('{}') I[03:30:27.300] ut symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 libLLVM.so.19.1 0x00007f1b8c46512f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63 1 libLLVM.so.19.1 0x00007f1b8c462e39 llvm::sys::RunSignalHandlers() + 89 2 libLLVM.so.19.1 0x00007f1b8c465880 3 libc.so.6 0x00007f1b8a6c9250 4 libclang-cpp.so.19.1 0x00007f1b94430402 clang::TypeLoc::getLocalAlignmentForType(clang::QualType) + 34 5 libclang-cpp.so.19.1 0x00007f1b94430485 clang::TypeLoc::getFullDataSizeForType(clang::QualType) + 101 6 libclang-cpp.so.19.1 0x00007f1b95005834 clang::TypeLocBuilder::pushTrivial(clang::ASTContext&, clang::QualType, clang::SourceLocation) + 68 7 libclang-cpp.so.19.1 0x00007f1b94f67653 8 libclang-cpp.so.19.1 0x00007f1b94f6734f 9 libclang-cpp.so.19.1 0x00007f1b94f1f71f 10 libclang-cpp.so.19.1 0x00007f1b94f266ab 11 libclang-cpp.so.19.1 0x00007f1b94f5f9a4 12 libclang-cpp.so.19.1 0x00007f1b94f5f2e1 13 libclang-cpp.so.19.1 0x00007f1b94f28716 14 libclang-cpp.so.19.1 0x00007f1b94f565d9 15 libclang-cpp.so.19.1 0x00007f1b94f26732 16 libclang-cpp.so.19.1 0x00007f1b94f5fa46 17 libclang-cpp.so.19.1 0x00007f1b94f5f2e1 18 libclang-cpp.so.19.1 0x00007f1b94f28716 19 libclang-cpp.so.19.1 0x00007f1b94f565d9 20 libclang-cpp.so.19.1 0x00007f1b94f26732 21 libclang-cpp.so.19.1 0x00007f1b94f5f9a4 22 libclang-cpp.so.19.1 0x00007f1b94f66916 23 libclang-cpp.so.19.1 0x00007f1b94f63e48 24 libclang-cpp.so.19.1 0x00007f1b94f1f71f 25 libclang-cpp.so.19.1 0x00007f1b94f266ab 26 libclang-cpp.so.19.1 0x00007f1b94f2652d clang::Sema::SubstTemplateArgument(clang::TemplateArgumentLoc const&, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentLoc&, clang::SourceLocation, clang::DeclarationName const&) + 77 27 libclang-cpp.so.19.1 0x00007f1b94de5599 28 libclang-cpp.so.19.1 0x00007f1b94de5125 clang::Sema::SubstDefaultTemplateArgumentIfAvailable(clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::Decl*, llvm::ArrayRef, llvm::ArrayRef, bool&) + 405 29 libclang-cpp.so.19.1 0x00007f1b94e6dc14 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl const*, bool, llvm::function_ref) + 1924 30 libclang-cpp.so.19.1 0x00007f1b94ecb657 31 libclang-cpp.so.19.1 0x00007f1b947042a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) + 64 32 libclang-cpp.so.19.1 0x00007f1b94e6fba0 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref)>) + 2912 33 libclang-cpp.so.19.1 0x00007f1b94d51906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) + 774 34 libclang-cpp.so.19.1 0x00007f1b94c23699 35 libclang-cpp.so.19.1 0x00007f1b94c169b4 36 libclang-cpp.so.19.1 0x00007f1b94c15ea4 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef) + 1780 37 libclang-cpp.so.19.1 0x00007f1b94de7018 clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) + 520 38 libclang-cpp.so.19.1 0x00007f1b94de6651 clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clI[03:30:27.300] Built preamble of size 0 for file /home/openvscode-server/latte/source/Tokenizer.hpp version 123 in ang::SourceLocation, unsigned int, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, clang::Sema::CheckTemplateArgumentKind) + 2113 0.78 seconds 39 libclang-cpp.so.19.1 0x00007f1b94ddb908 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, bool, bool*, bool) + 1256 I[03:30:27.300] --> workspace/semanticTokens/refresh(1) I[03:30:27.300] --> textDocument/clangd.fileStatus 40 libclang-cpp.so.19.1 0x00007f1b94e6c736 clang::Sema::SubstituteExplicitTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo&, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, clang::QualType*, clang::sema::TemplateDeductionInfo&) + 374 I[03:30:27.301] <-- reply(1) 41 libclang-cpp.so.19.1 0x00007f1b94ecb5b7 42 libclang-cpp.so.19.1 0x00007f1b947042a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) + 64 43 libclang-cpp.so.19.1 0x00007f1b94e6f2e1 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref)>) + 673 44 libclang-cpp.so.19.1 0x00007f1b94d51906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) + 774 45 libclang-cpp.so.19.1 0x00007f1b94d61e5d 46 libclang-cpp.so.19.1 0x00007f1b94d61d1e clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef, clang::OverloadCandidateSet&, bool) + 318 I[03:30:27.302] BeginSourceFile() failed when building AST for /home/openvscode-server/latte/source/Tokenizer.hpp I[03:30:27.302] --> textDocument/publishDiagnostics I[03:30:27.302] --> textDocument/clangd.fileStatus 47 libclang-cpp.so.19.1 0x00007f1b94d6207c clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult*) + 156 48 libclang-cpp.so.19.1 0x00007f1b94d6237d clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) + 365 49 libclang-cpp.so.19.1 0x00007f1b94a032a7 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) + 1527 50 libclang-cpp.so.19.1 0x00007f1b94a173c1 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*) + 81 51 libclang-cpp.so.19.1 0x00007f1b93dcbd8f clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult) + 5439 52 libclang-cpp.so.19.1 0x00007f1b93dcd4bc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) + 1900 53 libclang-cpp.so.19.1 0x00007f1b93dc8cbf clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 287 54 libclang-cpp.so.19.1 0x00007f1b93dc8b82 clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 18 55 libclang-cpp.so.19.1 0x00007f1b93e31f29 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) + 73 56 libclang-cpp.so.19.1 0x00007f1b93e3012d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) + 1085 57 libclang-cpp.so.19.1 0x00007f1b93e2faa6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) + 358 58 libclang-cpp.so.19.1 0x00007f1b93e38972 clang::Parser::ParseCompoundStatementBody(bool) + 1650 59 libclang-cpp.so.19.1 0x00007f1b93e39aaa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 186 60 libclang-cpp.so.19.1 0x00007f1b93e541d1 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 3889 61 libclang-cpp.so.19.1 0x00007f1b93d94547 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 6279 62 libclang-cpp.so.19.1 0x00007f1b93e530fd clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 1133 63 libclang-cpp.so.19.1 0x00007f1b93e52a65 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 565 64 libclang-cpp.so.19.1 0x00007f1b93e51c24 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 2164 65 libclang-cpp.so.19.1 0x00007f1b93e4ffb8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) + 1592 66 libclang-cpp.so.19.1 0x00007f1b93d7c4be clang::ParseAST(clang::Sema&, bool, bool) + 814 67 libclang-cpp.so.19.1 0x00007f1b95ecda0c clang::FrontendAction::Execute() + 92 68 clangd-19 0x00005576b322c533 69 clangd-19 0x00005576b32c7479 70 clangd-19 0x00005576b32c6eda 71 clangd-19 0x00005576b32c3680 72 clangd-19 0x00005576b32c31db 73 clangd-19 0x00005576b342c5d1 74 libc.so.6 0x00007f1b8a725e2e 75 libc.so.6 0x00007f1b8a7b7834 __clone + 68 Signalled during AST worker action: Build AST Filename: bug.hpp Directory: /home/openvscode-server/latte/source Command Line: /usr/lib/llvm-19/bin/clang++ --driver-mode=g++ -std=c++23 -stdlib=libc++ -resource-dir=/usr/lib/llvm-19/lib/clang/19 -- /home/openvscode-server/latte/source/bug.hpp Version: 62 [Error - 3:30:27 AM] 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. ```
llvmbot commented 3 days ago

@llvm/issue-subscribers-clangd

Author: Szymon Marczak (szmarczak)

```cpp #include <array> #include <iostream> template<typename T> struct ArrayType { template<size_t size> using Array = std::array<T, size>; }; template<ArrayType<int>::Array array> void test() { for (const auto& item : array) { std::cout << item << std::endl; } } void foo() { test<{1,2,3}>(); } ``` <details> <summary>It crashes clangd.</summary> ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. /home/openvscode-server/latte/source/bug.hpp:18:19: current parser token ')' 1. /home/openvscode-server/latte/source/bug.hpp:17:12: parsing function body 'foo' 2. /home/openvscode-server/latte/source/bug.hpp:17:12: in compound statement ('{}') I[03:30:27.300] ut symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 libLLVM.so.19.1 0x00007f1b8c46512f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63 1 libLLVM.so.19.1 0x00007f1b8c462e39 llvm::sys::RunSignalHandlers() + 89 2 libLLVM.so.19.1 0x00007f1b8c465880 3 libc.so.6 0x00007f1b8a6c9250 4 libclang-cpp.so.19.1 0x00007f1b94430402 clang::TypeLoc::getLocalAlignmentForType(clang::QualType) + 34 5 libclang-cpp.so.19.1 0x00007f1b94430485 clang::TypeLoc::getFullDataSizeForType(clang::QualType) + 101 6 libclang-cpp.so.19.1 0x00007f1b95005834 clang::TypeLocBuilder::pushTrivial(clang::ASTContext&, clang::QualType, clang::SourceLocation) + 68 7 libclang-cpp.so.19.1 0x00007f1b94f67653 8 libclang-cpp.so.19.1 0x00007f1b94f6734f 9 libclang-cpp.so.19.1 0x00007f1b94f1f71f 10 libclang-cpp.so.19.1 0x00007f1b94f266ab 11 libclang-cpp.so.19.1 0x00007f1b94f5f9a4 12 libclang-cpp.so.19.1 0x00007f1b94f5f2e1 13 libclang-cpp.so.19.1 0x00007f1b94f28716 14 libclang-cpp.so.19.1 0x00007f1b94f565d9 15 libclang-cpp.so.19.1 0x00007f1b94f26732 16 libclang-cpp.so.19.1 0x00007f1b94f5fa46 17 libclang-cpp.so.19.1 0x00007f1b94f5f2e1 18 libclang-cpp.so.19.1 0x00007f1b94f28716 19 libclang-cpp.so.19.1 0x00007f1b94f565d9 20 libclang-cpp.so.19.1 0x00007f1b94f26732 21 libclang-cpp.so.19.1 0x00007f1b94f5f9a4 22 libclang-cpp.so.19.1 0x00007f1b94f66916 23 libclang-cpp.so.19.1 0x00007f1b94f63e48 24 libclang-cpp.so.19.1 0x00007f1b94f1f71f 25 libclang-cpp.so.19.1 0x00007f1b94f266ab 26 libclang-cpp.so.19.1 0x00007f1b94f2652d clang::Sema::SubstTemplateArgument(clang::TemplateArgumentLoc const&, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentLoc&, clang::SourceLocation, clang::DeclarationName const&) + 77 27 libclang-cpp.so.19.1 0x00007f1b94de5599 28 libclang-cpp.so.19.1 0x00007f1b94de5125 clang::Sema::SubstDefaultTemplateArgumentIfAvailable(clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::Decl*, llvm::ArrayRef<clang::TemplateArgument>, llvm::ArrayRef<clang::TemplateArgument>, bool&) + 405 29 libclang-cpp.so.19.1 0x00007f1b94e6dc14 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool, llvm::function_ref<bool ()>) + 1924 30 libclang-cpp.so.19.1 0x00007f1b94ecb657 31 libclang-cpp.so.19.1 0x00007f1b947042a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) + 64 32 libclang-cpp.so.19.1 0x00007f1b94e6fba0 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) + 2912 33 libclang-cpp.so.19.1 0x00007f1b94d51906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) + 774 34 libclang-cpp.so.19.1 0x00007f1b94c23699 35 libclang-cpp.so.19.1 0x00007f1b94c169b4 36 libclang-cpp.so.19.1 0x00007f1b94c15ea4 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) + 1780 37 libclang-cpp.so.19.1 0x00007f1b94de7018 clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) + 520 38 libclang-cpp.so.19.1 0x00007f1b94de6651 clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clI[03:30:27.300] Built preamble of size 0 for file /home/openvscode-server/latte/source/Tokenizer.hpp version 123 in ang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::Sema::CheckTemplateArgumentKind) + 2113 0.78 seconds 39 libclang-cpp.so.19.1 0x00007f1b94ddb908 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, bool, bool*, bool) + 1256 I[03:30:27.300] --> workspace/semanticTokens/refresh(1) I[03:30:27.300] --> textDocument/clangd.fileStatus 40 libclang-cpp.so.19.1 0x00007f1b94e6c736 clang::Sema::SubstituteExplicitTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo&, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, llvm::SmallVectorImpl<clang::QualType>&, clang::QualType*, clang::sema::TemplateDeductionInfo&) + 374 I[03:30:27.301] <-- reply(1) 41 libclang-cpp.so.19.1 0x00007f1b94ecb5b7 42 libclang-cpp.so.19.1 0x00007f1b947042a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) + 64 43 libclang-cpp.so.19.1 0x00007f1b94e6f2e1 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) + 673 44 libclang-cpp.so.19.1 0x00007f1b94d51906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) + 774 45 libclang-cpp.so.19.1 0x00007f1b94d61e5d 46 libclang-cpp.so.19.1 0x00007f1b94d61d1e clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 318 I[03:30:27.302] BeginSourceFile() failed when building AST for /home/openvscode-server/latte/source/Tokenizer.hpp I[03:30:27.302] --> textDocument/publishDiagnostics I[03:30:27.302] --> textDocument/clangd.fileStatus 47 libclang-cpp.so.19.1 0x00007f1b94d6207c clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*) + 156 48 libclang-cpp.so.19.1 0x00007f1b94d6237d clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) + 365 49 libclang-cpp.so.19.1 0x00007f1b94a032a7 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) + 1527 50 libclang-cpp.so.19.1 0x00007f1b94a173c1 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) + 81 51 libclang-cpp.so.19.1 0x00007f1b93dcbd8f clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) + 5439 52 libclang-cpp.so.19.1 0x00007f1b93dcd4bc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) + 1900 53 libclang-cpp.so.19.1 0x00007f1b93dc8cbf clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 287 54 libclang-cpp.so.19.1 0x00007f1b93dc8b82 clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 18 55 libclang-cpp.so.19.1 0x00007f1b93e31f29 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) + 73 56 libclang-cpp.so.19.1 0x00007f1b93e3012d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) + 1085 57 libclang-cpp.so.19.1 0x00007f1b93e2faa6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) + 358 58 libclang-cpp.so.19.1 0x00007f1b93e38972 clang::Parser::ParseCompoundStatementBody(bool) + 1650 59 libclang-cpp.so.19.1 0x00007f1b93e39aaa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 186 60 libclang-cpp.so.19.1 0x00007f1b93e541d1 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 3889 61 libclang-cpp.so.19.1 0x00007f1b93d94547 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 6279 62 libclang-cpp.so.19.1 0x00007f1b93e530fd clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 1133 63 libclang-cpp.so.19.1 0x00007f1b93e52a65 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 565 64 libclang-cpp.so.19.1 0x00007f1b93e51c24 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 2164 65 libclang-cpp.so.19.1 0x00007f1b93e4ffb8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 1592 66 libclang-cpp.so.19.1 0x00007f1b93d7c4be clang::ParseAST(clang::Sema&, bool, bool) + 814 67 libclang-cpp.so.19.1 0x00007f1b95ecda0c clang::FrontendAction::Execute() + 92 68 clangd-19 0x00005576b322c533 69 clangd-19 0x00005576b32c7479 70 clangd-19 0x00005576b32c6eda 71 clangd-19 0x00005576b32c3680 72 clangd-19 0x00005576b32c31db 73 clangd-19 0x00005576b342c5d1 74 libc.so.6 0x00007f1b8a725e2e 75 libc.so.6 0x00007f1b8a7b7834 __clone + 68 Signalled during AST worker action: Build AST Filename: bug.hpp Directory: /home/openvscode-server/latte/source Command Line: /usr/lib/llvm-19/bin/clang++ --driver-mode=g++ -std=c++23 -stdlib=libc++ -resource-dir=/usr/lib/llvm-19/lib/clang/19 -- /home/openvscode-server/latte/source/bug.hpp Version: 62 [Error - 3:30:27 AM] 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. ``` </details>
szmarczak commented 3 days ago
$ clangd-19 --version
Ubuntu clangd version 19.1.1 (1ubuntu1)
Features: linux+grpc
Platform: x86_64-pc-linux-gnu
szmarczak commented 3 days ago
It crashes `clang` as well, not just `clangd`. ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /usr/lib/llvm-19/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir /home/openvscode-server/latte/out/latte- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/openvscode-server/latte -fcoverage-compilation-dir=/home/openvscode-server/latte -resource-dir /usr/lib/llvm-19/lib/clang/19 -internal-isystem /usr/lib/llvm-19/bin/../include/c++/v1 -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=c++23 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/main-67e185.o -x c++ /home/openvscode-server/latte/source/main.cpp 1. /home/openvscode-server/latte/source/Tokenizer.hpp:553:23: current parser token ')' 2. /home/openvscode-server/latte/source/Tokenizer.hpp:88:1: parsing struct/union/class body 'Tokenizer' 3. /home/openvscode-server/latte/source/Tokenizer.hpp:547:27: parsing function body 'Tokenizer::reset' 4. /home/openvscode-server/latte/source/Tokenizer.hpp:547:27: in compound statement ('{}') #0 0x00007f8ac360012f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xead12f) #1 0x00007f8ac35fde39 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xeaae39) #2 0x00007f8ac3600880 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xead880) #3 0x00007f8ac21d7250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250) #4 0x00007f8acb5cb402 clang::TypeLoc::getLocalAlignmentForType(clang::QualType) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x12f5402) #5 0x00007f8acb5cb485 clang::TypeLoc::getFullDataSizeForType(clang::QualType) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x12f5485) #6 0x00007f8acc1a0834 clang::TypeLocBuilder::pushTrivial(clang::ASTContext&, clang::QualType, clang::SourceLocation) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1eca834) #7 0x00007f8acc102653 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e2c653) #8 0x00007f8acc10234f (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e2c34f) #9 0x00007f8acc0ba71f (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1de471f) #10 0x00007f8acc0c16ab (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1deb6ab) #11 0x00007f8acc0fa9a4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e249a4) #12 0x00007f8acc0fa2e1 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e242e1) #13 0x00007f8acc0c3716 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ded716) #14 0x00007f8acc0f15d9 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e1b5d9) #15 0x00007f8acc0c1732 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1deb732) #16 0x00007f8acc0faa46 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e24a46) #17 0x00007f8acc0fa2e1 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e242e1) #18 0x00007f8acc0c3716 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ded716) #19 0x00007f8acc0f15d9 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e1b5d9) #20 0x00007f8acc0c1732 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1deb732) #21 0x00007f8acc0fa9a4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e249a4) #22 0x00007f8acc101916 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e2b916) #23 0x00007f8acc0fee48 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1e28e48) #24 0x00007f8acc0ba71f (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1de471f) #25 0x00007f8acc0c16ab (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1deb6ab) #26 0x00007f8acc0c152d clang::Sema::SubstTemplateArgument(clang::TemplateArgumentLoc const&, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentLoc&, clang::SourceLocation, clang::DeclarationName const&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1deb52d) #27 0x00007f8acbf80599 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1caa599) #28 0x00007f8acbf80125 clang::Sema::SubstDefaultTemplateArgumentIfAvailable(clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::Decl*, llvm::ArrayRef, llvm::ArrayRef, bool&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1caa125) #29 0x00007f8acc008c14 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl const*, bool, llvm::function_ref) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d32c14) #30 0x00007f8acc066657 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d90657) #31 0x00007f8acb89f2a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x15c92a0) #32 0x00007f8acc00aba0 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref)>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d34ba0) #33 0x00007f8acbeec906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1c16906) #34 0x00007f8acbdbe699 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ae8699) #35 0x00007f8acbdb19b4 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1adb9b4) #36 0x00007f8acbdb0ea4 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1adaea4) #37 0x00007f8acbf82018 clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1cac018) #38 0x00007f8acbf81651 clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, clang::Sema::CheckTemplateArgumentKind) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1cab651) #39 0x00007f8acbf76908 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, bool, bool*, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1ca0908) #40 0x00007f8acc007736 clang::Sema::SubstituteExplicitTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo&, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, clang::QualType*, clang::sema::TemplateDeductionInfo&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d31736) #41 0x00007f8acc0665b7 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d905b7) #42 0x00007f8acb89f2a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x15c92a0) #43 0x00007f8acc00a2e1 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref)>) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1d342e1) #44 0x00007f8acbeec906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1c16906) #45 0x00007f8acbefce5d (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1c26e5d) #46 0x00007f8acbefcd1e clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef, clang::OverloadCandidateSet&, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1c26d1e) #47 0x00007f8acbefd07c clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1c2707c) #48 0x00007f8acbefd37d clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x1c2737d) #49 0x00007f8acbb9e2a7 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x18c82a7) #50 0x00007f8acbbb23c1 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, clang::SourceLocation, clang::Expr*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x18dc3c1) #51 0x00007f8acaf66d8f clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc90d8f) #52 0x00007f8acaf684bc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc924bc) #53 0x00007f8acaf63cbf clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc8dcbf) #54 0x00007f8acaf63b82 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc8db82) #55 0x00007f8acafccf29 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcf6f29) #56 0x00007f8acafcb12d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcf512d) #57 0x00007f8acafcaaa6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcf4aa6) #58 0x00007f8acafd3972 clang::Parser::ParseCompoundStatementBody(bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcfd972) #59 0x00007f8acafd4aaa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xcfeaaa) #60 0x00007f8acaf1d173 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc47173) #61 0x00007f8acaf1bc5a clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc45c5a) #62 0x00007f8acaf562ce clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc802ce) #63 0x00007f8acaf5383b clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc7d83b) #64 0x00007f8acaf332af clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc5d2af) #65 0x00007f8acafedd5c clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd17d5c) #66 0x00007f8acafeda65 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd17a65) #67 0x00007f8acafecc24 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd16c24) #68 0x00007f8acafeafb8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xd14fb8) #69 0x00007f8acaf174be clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0xc414be) #70 0x00007f8acd068a0c clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2d92a0c) #71 0x00007f8accfdbde4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2d05de4) #72 0x00007f8acd0e824c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.1+0x2e1224c) #73 0x00005571981292c2 cc1_main(llvm::ArrayRef, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x132c2) #74 0x0000557198126294 (/usr/lib/llvm-19/bin/clang+0x10294) #75 0x0000557198125432 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xf432) #76 0x0000557198133773 main (/usr/lib/llvm-19/bin/clang+0x1d773) #77 0x00007f8ac21bc3b8 (/lib/x86_64-linux-gnu/libc.so.6+0x2a3b8) #78 0x00007f8ac21bc47b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a47b) #79 0x0000557198123e95 _start (/usr/lib/llvm-19/bin/clang+0xde95) clang++-19: error: unable to execute command: Segmentation fault (core dumped) clang++-19: error: clang frontend command failed due to signal (use -v to see invocation) Ubuntu clang version 19.1.1 (1ubuntu1) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-19/bin clang++-19: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang++-19: note: diagnostic msg: /tmp/main-e9e8be.cpp clang++-19: note: diagnostic msg: /tmp/main-e9e8be.sh clang++-19: note: diagnostic msg: ******************** ```
llvmbot commented 3 days ago

@llvm/issue-subscribers-clang-frontend

Author: Szymon Marczak (szmarczak)

```cpp #include <array> #include <iostream> template<typename T> struct ArrayType { template<size_t size> using Array = std::array<T, size>; }; template<ArrayType<int>::Array array> void test() { for (const auto& item : array) { std::cout << item << std::endl; } } void foo() { test<{1,2,3}>(); } ``` <details> <summary>It crashes clangd.</summary> ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. /home/openvscode-server/latte/source/bug.hpp:18:19: current parser token ')' 1. /home/openvscode-server/latte/source/bug.hpp:17:12: parsing function body 'foo' 2. /home/openvscode-server/latte/source/bug.hpp:17:12: in compound statement ('{}') I[03:30:27.300] ut symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 libLLVM.so.19.1 0x00007f1b8c46512f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63 1 libLLVM.so.19.1 0x00007f1b8c462e39 llvm::sys::RunSignalHandlers() + 89 2 libLLVM.so.19.1 0x00007f1b8c465880 3 libc.so.6 0x00007f1b8a6c9250 4 libclang-cpp.so.19.1 0x00007f1b94430402 clang::TypeLoc::getLocalAlignmentForType(clang::QualType) + 34 5 libclang-cpp.so.19.1 0x00007f1b94430485 clang::TypeLoc::getFullDataSizeForType(clang::QualType) + 101 6 libclang-cpp.so.19.1 0x00007f1b95005834 clang::TypeLocBuilder::pushTrivial(clang::ASTContext&, clang::QualType, clang::SourceLocation) + 68 7 libclang-cpp.so.19.1 0x00007f1b94f67653 8 libclang-cpp.so.19.1 0x00007f1b94f6734f 9 libclang-cpp.so.19.1 0x00007f1b94f1f71f 10 libclang-cpp.so.19.1 0x00007f1b94f266ab 11 libclang-cpp.so.19.1 0x00007f1b94f5f9a4 12 libclang-cpp.so.19.1 0x00007f1b94f5f2e1 13 libclang-cpp.so.19.1 0x00007f1b94f28716 14 libclang-cpp.so.19.1 0x00007f1b94f565d9 15 libclang-cpp.so.19.1 0x00007f1b94f26732 16 libclang-cpp.so.19.1 0x00007f1b94f5fa46 17 libclang-cpp.so.19.1 0x00007f1b94f5f2e1 18 libclang-cpp.so.19.1 0x00007f1b94f28716 19 libclang-cpp.so.19.1 0x00007f1b94f565d9 20 libclang-cpp.so.19.1 0x00007f1b94f26732 21 libclang-cpp.so.19.1 0x00007f1b94f5f9a4 22 libclang-cpp.so.19.1 0x00007f1b94f66916 23 libclang-cpp.so.19.1 0x00007f1b94f63e48 24 libclang-cpp.so.19.1 0x00007f1b94f1f71f 25 libclang-cpp.so.19.1 0x00007f1b94f266ab 26 libclang-cpp.so.19.1 0x00007f1b94f2652d clang::Sema::SubstTemplateArgument(clang::TemplateArgumentLoc const&, clang::MultiLevelTemplateArgumentList const&, clang::TemplateArgumentLoc&, clang::SourceLocation, clang::DeclarationName const&) + 77 27 libclang-cpp.so.19.1 0x00007f1b94de5599 28 libclang-cpp.so.19.1 0x00007f1b94de5125 clang::Sema::SubstDefaultTemplateArgumentIfAvailable(clang::TemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::Decl*, llvm::ArrayRef<clang::TemplateArgument>, llvm::ArrayRef<clang::TemplateArgument>, bool&) + 405 29 libclang-cpp.so.19.1 0x00007f1b94e6dc14 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool, llvm::function_ref<bool ()>) + 1924 30 libclang-cpp.so.19.1 0x00007f1b94ecb657 31 libclang-cpp.so.19.1 0x00007f1b947042a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) + 64 32 libclang-cpp.so.19.1 0x00007f1b94e6fba0 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) + 2912 33 libclang-cpp.so.19.1 0x00007f1b94d51906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) + 774 34 libclang-cpp.so.19.1 0x00007f1b94c23699 35 libclang-cpp.so.19.1 0x00007f1b94c169b4 36 libclang-cpp.so.19.1 0x00007f1b94c15ea4 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) + 1780 37 libclang-cpp.so.19.1 0x00007f1b94de7018 clang::Sema::CheckTemplateArgument(clang::NonTypeTemplateParmDecl*, clang::QualType, clang::Expr*, clang::TemplateArgument&, clang::TemplateArgument&, clang::Sema::CheckTemplateArgumentKind) + 520 38 libclang-cpp.so.19.1 0x00007f1b94de6651 clang::Sema::CheckTemplateArgument(clang::NamedDecl*, clang::TemplateArgumentLoc&, clang::NamedDecl*, clang::SourceLocation, clI[03:30:27.300] Built preamble of size 0 for file /home/openvscode-server/latte/source/Tokenizer.hpp version 123 in ang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, clang::Sema::CheckTemplateArgumentKind) + 2113 0.78 seconds 39 libclang-cpp.so.19.1 0x00007f1b94ddb908 clang::Sema::CheckTemplateArgumentList(clang::TemplateDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo&, bool, llvm::SmallVectorImpl<clang::TemplateArgument>&, llvm::SmallVectorImpl<clang::TemplateArgument>&, bool, bool*, bool) + 1256 I[03:30:27.300] --> workspace/semanticTokens/refresh(1) I[03:30:27.300] --> textDocument/clangd.fileStatus 40 libclang-cpp.so.19.1 0x00007f1b94e6c736 clang::Sema::SubstituteExplicitTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo&, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, llvm::SmallVectorImpl<clang::QualType>&, clang::QualType*, clang::sema::TemplateDeductionInfo&) + 374 I[03:30:27.301] <-- reply(1) 41 libclang-cpp.so.19.1 0x00007f1b94ecb5b7 42 libclang-cpp.so.19.1 0x00007f1b947042a0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) + 64 43 libclang-cpp.so.19.1 0x00007f1b94e6f2e1 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) + 673 44 libclang-cpp.so.19.1 0x00007f1b94d51906 clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) + 774 45 libclang-cpp.so.19.1 0x00007f1b94d61e5d 46 libclang-cpp.so.19.1 0x00007f1b94d61d1e clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 318 I[03:30:27.302] BeginSourceFile() failed when building AST for /home/openvscode-server/latte/source/Tokenizer.hpp I[03:30:27.302] --> textDocument/publishDiagnostics I[03:30:27.302] --> textDocument/clangd.fileStatus 47 libclang-cpp.so.19.1 0x00007f1b94d6207c clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*) + 156 48 libclang-cpp.so.19.1 0x00007f1b94d6237d clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) + 365 49 libclang-cpp.so.19.1 0x00007f1b94a032a7 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) + 1527 50 libclang-cpp.so.19.1 0x00007f1b94a173c1 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) + 81 51 libclang-cpp.so.19.1 0x00007f1b93dcbd8f clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) + 5439 52 libclang-cpp.so.19.1 0x00007f1b93dcd4bc clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) + 1900 53 libclang-cpp.so.19.1 0x00007f1b93dc8cbf clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 287 54 libclang-cpp.so.19.1 0x00007f1b93dc8b82 clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 18 55 libclang-cpp.so.19.1 0x00007f1b93e31f29 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) + 73 56 libclang-cpp.so.19.1 0x00007f1b93e3012d clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) + 1085 57 libclang-cpp.so.19.1 0x00007f1b93e2faa6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) + 358 58 libclang-cpp.so.19.1 0x00007f1b93e38972 clang::Parser::ParseCompoundStatementBody(bool) + 1650 59 libclang-cpp.so.19.1 0x00007f1b93e39aaa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 186 60 libclang-cpp.so.19.1 0x00007f1b93e541d1 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 3889 61 libclang-cpp.so.19.1 0x00007f1b93d94547 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 6279 62 libclang-cpp.so.19.1 0x00007f1b93e530fd clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 1133 63 libclang-cpp.so.19.1 0x00007f1b93e52a65 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 565 64 libclang-cpp.so.19.1 0x00007f1b93e51c24 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 2164 65 libclang-cpp.so.19.1 0x00007f1b93e4ffb8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 1592 66 libclang-cpp.so.19.1 0x00007f1b93d7c4be clang::ParseAST(clang::Sema&, bool, bool) + 814 67 libclang-cpp.so.19.1 0x00007f1b95ecda0c clang::FrontendAction::Execute() + 92 68 clangd-19 0x00005576b322c533 69 clangd-19 0x00005576b32c7479 70 clangd-19 0x00005576b32c6eda 71 clangd-19 0x00005576b32c3680 72 clangd-19 0x00005576b32c31db 73 clangd-19 0x00005576b342c5d1 74 libc.so.6 0x00007f1b8a725e2e 75 libc.so.6 0x00007f1b8a7b7834 __clone + 68 Signalled during AST worker action: Build AST Filename: bug.hpp Directory: /home/openvscode-server/latte/source Command Line: /usr/lib/llvm-19/bin/clang++ --driver-mode=g++ -std=c++23 -stdlib=libc++ -resource-dir=/usr/lib/llvm-19/lib/clang/19 -- /home/openvscode-server/latte/source/bug.hpp Version: 62 [Error - 3:30:27 AM] 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. ``` </details>
shafik commented 3 days ago

This is a regression in clang trunk: https://godbolt.org/z/rarc6EbYs

CC @cor3ntin

cor3ntin commented 3 days ago

@mizvekov