-
Notifications
You must be signed in to change notification settings - Fork 65
Description
When the clangd LS gets restarted due to a change in the compile_commands.json or the user has modified the LS settings in the preferences and a C/C++ file which is connected to the LS is being opened in the editor it crashes like this:
I did some debugging and found out that it crashes since this PR #1266
It is triggered by the disconnectTextFileBuffer call in the LanguageServerWrapper class. All documents in the file buffers getting disconnected and buffer will be cleared. When a file is still open in an editor, the LSP4E framework does the enable checks for a lot of editor providers after restart. To check if the LS should be enabled for the given file, it tries to fetch the document. First attempt is to check via the file buffer manager. This fails because the prior stop disconnected all files from the buffer.
So it will be loaded temporarily for the check (see screenshot below). After the check, the file buffer will be cleared which triggers a fireBufferDisposed event which calls the org.eclipse.lsp4e.LanguageServerWrapper.LSFileBufferListener.bufferDisposed(IFileBuffer) again which calls disconnect(URI uri) which calls startStopTimerTask() in every check...
Something in this repeating calls triggers the behavior described above. It happens on some Linus distros only (for example Linux Mint, Ubuntu 22.04 LTS). I could not reproduce this behavior on a Windows 11 machine. It may depends on the used Java environment.
A solution could be to not remove documents from file buffer which are still opened in an editor.
See also this cdt-lsp bug issue eclipse-cdt/cdt-lsp#525