<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114571>114571</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clangd: language server crashing, std::bad_array_new_length
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
olemayu
</td>
</tr>
</table>
<pre>
I suddenly started having clangd constanstly crashing on me even on a clean directory without any special setups. I do not recall doing anything special or changing anything.
```c
int main(int argc, char* argv[]) {
if (argc < 2) {
return 0;
}
return 0;
}
```
```
I[16:47:18.853] Ubuntu clangd version 20.0.0 (++20241030081643+f3584222682b-1~exp1~20241030081752.508)
I[16:47:18.853] Features: linux+grpc
I[16:47:18.853] PID: 883
I[16:47:18.854] Working directory: /developement/test_clangd
I[16:47:18.854] argv[0]: /usr/bin/clangd
I[16:47:18.854] argv[1]: --function-arg-placeholders=0
I[16:47:18.854] argv[2]: --header-insertion=never
I[16:47:18.854] argv[3]: --rename-file-limit=0
I[16:47:18.854] Starting LSP over stdin/stdout
I[16:47:18.854] <-- initialize(0)
I[16:47:18.855] --> reply:initialize(0) 0 ms
I[16:47:18.856] <-- initialized
I[16:47:18.857] <-- textDocument/didOpen
I[16:47:18.859] --> textDocument/publishDiagnostics
I[16:47:18.859] Failed to find compilation database for /developement/test_clangd/source.c
I[16:47:18.859] ASTWorker building file /developement/test_clangd/source.c version 1 with command clangd fallback
[/developement/test_clangd]
/usr/lib/llvm-20/bin/clang -resource-dir=/usr/lib/clang/20 -- /developement/test_clangd/source.c
I[16:47:18.860] --> textDocument/clangd.fileStatus
I[16:47:18.869] Built preamble of size 294440 for file /developement/test_clangd/source.c version 1 in 0.01 seconds
I[16:47:18.869] --> workspace/semanticTokens/refresh(0)
I[16:47:18.870] <-- reply(0)
I[16:47:18.871] <-- textDocument/documentSymbol(1)
I[16:47:18.871] <-- textDocument/documentLink(2)
I[16:47:18.871] <-- textDocument/codeAction(3)
I[16:47:18.875] --> textDocument/publishDiagnostics
I[16:47:18.875] --> textDocument/inactiveRegions
terminate called after throwing an instance of 'std::bad_array_new_length'
what(): std::bad_array_new_length
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
I[16:47:18.877] <-- textDocument/semanticTokens/full(4)
I[16:47:19.060] <-- textDocument/foldingRange(5)
I[16:47:19.060] --> reply:textDocument/foldingRange(5) 0 ms
I[16:47:19.145] <-- textDocument/documentSymbol(6)
#0 0x00007fa8fc094d8f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM.so.20.0+0xfd8d8f)
#1 0x00007fa8fc092a99 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM.so.20.0+0xfd6a99)
#2 0x00007fa8fc0954a0 (/lib/x86_64-linux-gnu/libLLVM.so.20.0+0xfd94a0)
#3 0x00007fa8fa21f320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
#4 0x00007fa8fa278b1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007fa8fa278b1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007fa8fa278b1c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007fa8fa21f26e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007fa8fa2028ff abort ./stdlib/abort.c:81:7
#9 0x00007fa8fa5a8ff5 __gnu_cxx::__verbose_terminate_handler() /build/gcc-14-ig5ci0/gcc-14-14.2.0/build/x86_64-linux-gnu/libstdc++-v3/libsupc++/../../../../src/libstdc++-v3/libsupc++/vterminate.cc:75:10
#10 0x00007fa8fa5be0da __cxxabiv1::__terminate(void (*)()) /build/gcc-14-ig5ci0/gcc-14-14.2.0/build/x86_64-linux-gnu/libstdc++-v3/libsupc++/../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:48:15
#11 0x00007fa8fa5a8a55 std::unexpected() /build/gcc-14-ig5ci0/gcc-14-14.2.0/build/x86_64-linux-gnu/libstdc++-v3/libsupc++/../../../../src/libstdc++-v3/libsupc++/eh_terminate.cc:71:1
#12 0x00007fa8fa5be391 (/lib/x86_64-linux-gnu/libstdc++.so.6+0xbb391)
#13 0x00007fa8fa5ac111 std::__throw_bad_cast() /build/gcc-14-ig5ci0/gcc-14-14.2.0/build/x86_64-linux-gnu/libstdc++-v3/src/c++11/../../../../../src/libstdc++-v3/src/c++11/functexcept.cc:62:3
#14 0x0000562375535217 (/usr/bin/clangd+0x369217)
#15 0x0000562375513ead (/usr/bin/clangd+0x347ead)
#16 0x0000562375514443 (/usr/bin/clangd+0x348443)
#17 0x00005623757ae700 (/usr/bin/clangd+0x5e2700)
#18 0x000056237565df94 (/usr/bin/clangd+0x491f94)
#19 0x000056237565d71a (/usr/bin/clangd+0x49171a)
#20 0x0000562375659f8e (/usr/bin/clangd+0x48df8e)
#21 0x0000562375659b2b (/usr/bin/clangd+0x48db2b)
#22 0x00005623757c2981 (/usr/bin/clangd+0x5f6981)
#23 0x00007fa8fa276a94 start_thread ./nptl/pthread_create.c:447:8
#24 0x00007fa8fa303c3c clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80:0
Signalled during AST worker action: Build AST
Filename: source.c
Directory: /developement/test_clangd
Command Line: /usr/lib/llvm-20/bin/clang -resource-dir=/usr/lib/clang/20 -- /developement/test_clangd/source.c
Version: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUmVtv47gVgH8N80JY4EXXBz84kzU6QIoOJtPto0FRRzYbmjJIyon3YX97QcqxLSe2s7Mtih0MDF3IT4fnTkY4p5YGYIqye5Q93Inerzo77TSsxa6_q7tmN_2KXd80YPQOOy-shwavxFaZJZZamGWDZWecF8Z5vcPSCrcK7zqD14BhCyZcCiw1CIMbZUH6zu7wi_KrrvdYmB12G5BKaOzA9xuX4K-46bDpPLYghda46QJRmJ2P6LfhncVyJczy9GWCyAMis_1v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