llvm / llvm-project

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

clangd: language server crashing, std::bad_array_new_length #114571

Open olemayu opened 2 hours ago

olemayu commented 2 hours ago

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.

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
llvmbot commented 2 hours ago

@llvm/issue-subscribers-clangd

Author: None (olemayu)

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 ```