[clangd][clang]didOpen-only assertion `NumChunks <= 0xffff`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This input is reduced from [clang/test/Parser/function-parameter-limit.cpp](https://github.com/llvm/llvm-project/blob/main/clang/test/Parser/function-parameter-limit.cpp):
```
#define a(b) b, b, b, b, b, b, b, b, b, b,
#define c(b) a(b) a(b) a(b) a(b) a(b)
#define d(b) c(b) c(b) c(b) c(b) c(b) c(b) c(b) c(b) c(b) c(b)
#define n(b) d(b) d(b) d(b) d(b) d(b) d(b) d(b) d(b) d(b) d(b)
e(n(f) n(g) n(h) n(i) n(j) n(k) n(l m);
```
stacktrace:
```
cat harness/cases/CASE-20260514-016/artifacts/last_replay.log | scripts/sanitize_paths.py
I[18:23:54.750] clangd version 23.0.0git (https://github.com/llvm/llvm-project.git c75e1e62d11be965a4dca0d816a4d19a6684b043)
I[18:23:54.750] Features: linux+debug-tidy
I[18:23:54.750] PID: 34
I[18:23:54.750] Working directory: /harness/cases/CASE-20260514-016/workspace
I[18:23:54.750] argv[0]: /tmp/build-assert-clangd-main-20260506/bin/clangd
I[18:23:54.750] argv[1]: --background-index=0
I[18:23:54.750] argv[2]: --clang-tidy=0
I[18:23:54.751] Starting LSP over stdin/stdout
I[18:23:54.754] <-- initialize(1)
I[18:23:54.757] --> reply:initialize(1) 3 ms
Content-Length: 2077
{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":true,"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":{"rangesSupport":true},"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyRename","clangd.applyTweak"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inactiveRegionsProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","definition","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","usedAsMutablePointer","constructorOrDestructor","userDefined","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","modifier","operator","bracket","label","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 23.0.0git (https://github.com/llvm/llvm-project.git c75e1e62d11be965a4dca0d816a4d19a6684b043) linux+debug-tidy x86_64-unknown-linux-gnu"}}}I[18:23:54.758] <-- initialized
I[18:23:54.758] <-- textDocument/didOpen
I[18:23:54.761] Loaded compilation database from /harness/cases/CASE-20260514-016/workspace/compile_commands.json
I[18:23:54.761] ASTWorker building file /harness/cases/CASE-20260514-016/workspace/function-parameter-limit.cpp version 1 with command
[/harness/cases/CASE-20260514-016/workspace]
/usr/lib/llvm-18/bin/clang++ --driver-mode=g++ -std=c++26 -fsyntax-only -I/harness/cases/CASE-20260514-016/workspace/Inputs -resource-dir=/tmp/build-assert-clangd-main-20260506/lib/clang/23 -- /harness/cases/CASE-20260514-016/workspace/function-parameter-limit.cpp
I[18:23:54.814] Built preamble of size 252608 for file /harness/cases/CASE-20260514-016/workspace/function-parameter-limit.cpp version 1 in 0.04 seconds
I[18:23:54.821] Indexing c++23 standard library in the context of /harness/cases/CASE-20260514-016/workspace/function-parameter-limit.cpp
I[18:23:56.703] Indexed c++23 standard library: 16529 symbols, 2887 filtered
I[18:23:57.770] <-- shutdown(2)
I[18:23:57.770] --> reply:shutdown(2) 0 ms
Content-Length: 38
{"id":2,"jsonrpc":"2.0","result":null}I[18:23:57.781] <-- exit
I[18:23:57.781] LSP finished, exiting with status 0
clangd: /tmp/llvm-project-main-20260504/clang/lib/Sema/CodeCompleteConsumer.cpp:292: clang::CodeCompletionString::CodeCompletionString(const Chunk*, unsigned int, unsigned int, CXAvailabilityKind, const char**, unsigned int, llvm::StringRef, const char*): Assertion `NumChunks <= 0xffff' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
#0 0x00005973d73a18f2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /tmp/llvm-project-main-20260504/llvm/lib/Support/Unix/Signals.inc:884:3
#1 0x00005973d739e66c llvm::sys::RunSignalHandlers() /tmp/llvm-project-main-20260504/llvm/lib/Support/Signals.cpp:108:20
#2 0x00005973d739eee1 SignalHandler(int, siginfo_t*, void*) /tmp/llvm-project-main-20260504/llvm/lib/Support/Unix/Signals.inc:448:14
#3 0x0000797525245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000079752529eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000079752529eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000079752529eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000079752524527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007975252288ff abort ./stdlib/abort.c:81:7
#9 0x000079752522881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000079752523b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x00005973d8745364 clang::CodeCompletionString::CodeCompletionString(clang::CodeCompletionString::Chunk const*, unsigned int, unsigned int, CXAvailabilityKind, char const**, unsigned int, llvm::StringRef, char const*) /tmp/llvm-project-main-20260504/clang/lib/Sema/CodeCompleteConsumer.cpp:293:3
#12 0x00005973d874993e llvm::SmallVectorImpl::clear() /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/SmallVector.h:618:16
#13 0x00005973d874993e clang::CodeCompletionBuilder::TakeString() /tmp/llvm-project-main-20260504/clang/lib/Sema/CodeCompleteConsumer.cpp:440:15
#14 0x00005973d8156c07 clang::CodeCompletionResult::createCodeCompletionStringForDecl(clang::Preprocessor&, clang::ASTContext&, clang::CodeCompletionBuilder&, bool, clang::CodeCompletionContext const&, clang::PrintingPolicy&) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaCodeComplete.cpp:3866:30
#15 0x00005973d81617e2 clang::CodeCompletionResult::CreateCodeCompletionString(clang::ASTContext&, clang::Preprocessor&, clang::CodeCompletionContext const&, clang::CodeCompletionAllocator&, clang::CodeCompletionTUInfo&, bool) (.part.0) /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaCodeComplete.cpp:3750:43
#16 0x00005973d8c1c3f7 clang::clangd::SymbolCollector::addDeclaration(clang::NamedDecl const&, clang::clangd::SymbolID, bool) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/index/SymbolCollector.cpp:1110:64
#17 0x00005973d8c1d462 clang::clangd::SymbolCollector::handleDeclOccurrence(clang::Decl const*, unsigned int, llvm::ArrayRef, clang::SourceLocation, clang::index::IndexDataConsumer::ASTNodeInfo) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/index/SymbolCollector.cpp:728:33
#18 0x00005973d8c74d7b llvm::SmallVectorTemplateCommon::isSmall() const /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/SmallVector.h:148:39
#19 0x00005973d8c74d7b llvm::SmallVectorImpl::~SmallVectorImpl() /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/SmallVector.h:609:23
#20 0x00005973d8c74d7b llvm::SmallVector::~SmallVector() /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/SmallVector.h:1230:3
#21 0x00005973d8c74d7b clang::index::IndexingContext::handleDeclOccurrence(clang::Decl const*, clang::SourceLocation, bool, clang::Decl const*, unsigned int, llvm::ArrayRef, clang::Expr const*, clang::Decl const*, clang::DeclContext const*) /tmp/llvm-project-main-20260504/clang/lib/Index/IndexingContext.cpp:426:34
#22 0x00005973d8c753b6 clang::index::IndexingContext::handleDecl(clang::Decl const*, clang::SourceLocation, unsigned int, llvm::ArrayRef, clang::DeclContext const*) /tmp/llvm-project-main-20260504/clang/lib/Index/IndexingContext.cpp:84:1
#23 0x00005973d8c7543a clang::index::IndexingContext::handleDecl(clang::Decl const*, unsigned int, llvm::ArrayRef) /tmp/llvm-project-main-20260504/clang/lib/Index/IndexingContext.cpp:68:1
#24 0x00005973d8c77c11 (anonymous namespace)::IndexingDeclVisitor::VisitFunctionDecl(clang::FunctionDecl const*) /tmp/llvm-project-main-20260504/clang/lib/Index/IndexDecl.cpp:259:5
#25 0x00005973d8c7aa6b clang::index::IndexingContext::indexDecl(clang::Decl const*) /tmp/llvm-project-main-20260504/clang/lib/Index/IndexDecl.cpp:789:3
#26 0x00005973d8c72907 clang::index::indexTopLevelDecls(clang::ASTContext&, clang::Preprocessor&, llvm::ArrayRef, clang::index::IndexDataConsumer&, clang::index::IndexingOptions) /tmp/llvm-project-main-20260504/clang/lib/Index/IndexingAction.cpp:294:24
#27 0x00005973d8be59a2 std::_Function_base::~_Function_base() /usr/include/c++/13/bits/std_function.h:243:11
#28 0x00005973d8be59a2 std::function::~function() /usr/include/c++/13/bits/std_function.h:334:11
#29 0x00005973d8be59a2 clang::index::IndexingOptions::~IndexingOptions() /tmp/llvm-project-main-20260504/clang/include/clang/Index/IndexingOptions.h:20:8
#30 0x00005973d8be59a2 clang::clangd::(anonymous namespace)::indexSymbols(clang::ASTContext&, clang::Preprocessor&, llvm::ArrayRef, clang::clangd::MainFileMacros const*, clang::include_cleaner::PragmaIncludes const&, bool, llvm::StringRef, bool, clang::clangd::SymbolOrigin) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/index/FileIndex.cpp:82:28
#31 0x00005973d8be6406 clang::clangd::indexMainDecls(clang::clangd::ParsedAST&) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/index/FileIndex.cpp:228:71
#32 0x00005973d8be6481 clang::clangd::FileIndex::updateMain(llvm::StringRef, clang::clangd::ParsedAST&) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/index/FileIndex.cpp:473:25
#33 0x00005973d8832891 clang::clangd::(anonymous namespace)::UpdateIndexCallbacks::onMainAST(llvm::StringRef, clang::clangd::ParsedAST&, llvm::function_ref)>) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/ClangdServer.cpp:139:5
#34 0x00005973d8a90b62 clang::clangd::(anonymous namespace)::ASTWorker::generateDiagnostics(std::unique_ptr>, clang::clangd::ParseInputs, std::vector>) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1251:24
#35 0x00005973d8a90f50 std::unique_ptr>::~unique_ptr() /usr/include/c++/13/bits/unique_ptr.h:403:12
#36 0x00005973d8a90f50 clang::clangd::(anonymous namespace)::ASTWorker::updatePreamble(std::unique_ptr>, clang::clangd::ParseInputs, std::shared_ptr, std::vector>, clang::clangd::WantDiagnostics)::'lambda'()::operator()() (.part.0) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1147:24
#37 0x00005973d8a852aa clang::clangd::(anonymous namespace)::ASTWorker::runTask(llvm::StringRef, llvm::function_ref) /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1328:1
#38 0x00005973d8a889fa clang::clangd::(anonymous namespace)::ASTWorker::run() /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1462:5
#39 0x00005973d8c6bb6e llvm::detail::UniqueFunctionBase::operator=(llvm::detail::UniqueFunctionBase&&) /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:329:5
#40 0x00005973d8c6bb6e llvm::detail::UniqueFunctionBase::operator=(llvm::detail::UniqueFunctionBase&&) /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:321:23
#41 0x00005973d8c6bb6e llvm::unique_function::operator=(llvm::unique_function&&) /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:352:20
#42 0x00005973d8c6bb6e operator() /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/support/Threading.cpp:103:14
#43 0x00005973d8c6bb6e operator())::&> /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:46:16
#44 0x00005973d8c6bb6e __invoke_impl):: > >(void*)::, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> /usr/include/c++/13/bits/invoke.h:61:36
#45 0x00005973d8c6bb6e __invoke):: > >(void*)::, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> /usr/include/c++/13/bits/invoke.h:96:40
#46 0x00005973d8c6bb6e __apply_impl):: > >(void*)::, std::tuple):: >&, 0> /usr/include/c++/13/tuple:2302:27
#47 0x00005973d8c6bb6e apply):: > >(void*)::, std::tuple):: >&> /usr/include/c++/13/tuple:2313:31
#48 0x00005973d8c6bb6e GenericThreadProxy):: > > /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:44:15
#49 0x00005973d8c6bb6e void* llvm::thread::ThreadProxy)::'lambda0'()>>(void*) /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:62:36
#50 0x000079752529caa4 start_thread ./nptl/pthread_create.c:447:8
#51 0x0000797525329c6c clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80:0
Signalled during AST worker action: Build AST
Filename: /harness/cases/CASE-20260514-016/workspace/function-parameter-limit.cpp
Directory: /harness/cases/CASE-20260514-016/workspace
Command Line: /usr/lib/llvm-18/bin/clang++ --driver-mode=g++ -std=c++26 -fsyntax-only -I/harness/cases/CASE-20260514-016/workspace/Inputs -resource-dir=/tmp/build-assert-clangd-main-20260506/lib/clang/23 -- /harness/cases/CASE-20260514-016/workspace/function-parameter-limit.cpp
Version: 1
/harness/scripts/run_clangd_didopen_workspace.sh: line 91: 33 Done { emit_lsp "$INIT"; emit_lsp "$INITIALIZED"; emit_lsp "$DIDOPEN"; sleep "$DIDOPEN_WAIT_SECS"; emit_lsp "$SHUTDOWN"; emit_lsp "$EXIT"; }
34 Aborted (core dumped) | ( cd "$WORKDIR"; "$TARGET" "${TARGET_ARGS[@]}" )
```
Contributor guide
Assessment
This issue has not been assessed yet.