vscode-clangd icon indicating copy to clipboard operation
vscode-clangd copied to clipboard

clangd will hang up after frequently renaming

Open rockingdice opened this issue 3 years ago • 5 comments

I did a massive renaming (renaming variables one by one) and it suddenly stopped working. The status always remains: image

After that, all functions from clangd are not working. I also tested with the AST plugin of Sublime, and it works without any issues.

Logs Please attach the clangd log from the "Output" window if you can. If possible, run with --log=verbose - note that the logs will include the contents of open files! The logs file is attached.

System information Clangd version (from the log, or clangd --version): Apple clangd version 13.1.6 (clang-1316.0.21.2.5) Features: mac+xpc clangd extension version: v0.1.21 Operating system: mac 12.5.1 clangd-logs.txt

rockingdice avatar Sep 06 '22 01:09 rockingdice

Does restarting clangd help, or does the non-responsiveness persist after a restart?

HighCommander4 avatar Sep 06 '22 07:09 HighCommander4

@HighCommander4 A cold restart of vscode will fix the problem, I don't know how to restart clangd.

rockingdice avatar Sep 09 '22 09:09 rockingdice

@HighCommander4 A cold restart of vscode will fix the problem, I don't know how to restart clangd.

There is a command to restart clangd. Open the command palette and type clangd, I'm sure it will pop up.

njames93 avatar Sep 09 '22 15:09 njames93

A few thoughts:

This is Apple's fork of clangd, not a release from us. The first thing would be to see if it's already fixed in clangd 15 (check the releases page).

Realistically i think this is going to be hard to debug without reducing the example to a manageable size that can be reproduced and including verbose logs.

My best guess: soon after the renames, we see a flood of didOpen notifications. Did the rename affect many files, which then got automatically opened in VSCode? This could be overwhelming clangd somehow.

  • VSCode usually is lazy about notifying clangd of files that are "opened" in a background tab, but i suppose edits would force them to be sent
  • clangd should make progress through a queue rather than just getting stuck. We only start parsing some of the files that are open, this is consistent with the parses being stuck somehow, we hit our max parallelism, and the other AST threads starve.

sam-mccall avatar Sep 09 '22 22:09 sam-mccall

@njames93 thanks for your info, I'll try when I have the chance to reproduce this bug. @sam-mccall renaming did affect a few files, in fact, some are even more than a hundred files. I don't remember VSCode will open those files or not, but Sublime did open those files, it also prompts a dialog for the user to choose whether to replace them if affects multiple files, so there's no problem for Sublime, because I have to confirm before the next renaming operation - it's enough time for clangd to handle things. I did the renaming quite quickly with VSCode, might be once in two seconds or less (thanks for the hotkeys and no confirm prompts!). If i/o time matters, any chance that the renaming operations are executed incorrectly?

I met another bug but don't know when it will happen and if it's related so I just record it here as a side note: After all the renaming, I noticed some variables are not renamed correctly: they are in the same line, only the first one is renamed correctly, latter variables are corrupted (though the lengths after replacing are correct, only the content are wrong). During the renaming operations, I switched from VSCode to Sublime, and did some undos after renaming.

rockingdice avatar Sep 11 '22 04:09 rockingdice