clangd icon indicating copy to clipboard operation
clangd copied to clipboard

clangd Hangs after running `assert([{,}])`

Open mQfZ opened this issue 1 year ago • 5 comments

clangd seems to hang for no apparent reason from an assert call.

Screenshot 2024-01-01 at 1 55 29 AM

Screenshot 2024-01-01 at 1 56 58 AM

I tried multiple versions of clangd, but all of them seemed to hang. This could be a clangd problem, but I couldn't reproduce the error in another text editor.

Clangd version (from the log, or clangd --version): 17.0.6 clangd extension version: v0.1.26 Operating system: Mac

mQfZ avatar Jan 01 '24 07:01 mQfZ

I can reproduce this. The hang is in SelectionVisitor::claimRange(), invoked during textDocument/codeAction.

HighCommander4 avatar Jan 01 '24 07:01 HighCommander4

An assertions-enabled build crashes with:

clang-tools-extra/clangd/Selection.cpp:330: SelectionTree::Selection clang::clangd::(anonymous namespace)::SelectionTester::test(llvm::ArrayRefsyntax::Token) const: Assertion `!Batch.empty()' failed

HighCommander4 avatar Jan 01 '24 07:01 HighCommander4

Based on the previous comments, this is definitely a server-side issue.

Not happening with other editors is probably related to other editors not sending textDocument/codeAction as aggressively (i.e. without explicit invocation).

HighCommander4 avatar Jan 01 '24 07:01 HighCommander4

Looks like the same issue as https://github.com/llvm/llvm-project/issues/58482. There's some analysis in that issue, I'll close this one as a dupe.

HighCommander4 avatar Jan 15 '24 02:01 HighCommander4

Duplicate of https://github.com/llvm/llvm-project/issues/58482

HighCommander4 avatar Jan 15 '24 02:01 HighCommander4