eclipse-lsp4e / eclipse-lsp4e/lsp4e

Multiple server instances where started for a document when singleton=false

Open
#512 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
85
Forks
69
Avg merge
8h 33m
Merged PRs (30d)
6

Description

Description:
Several language server instances gets started for a file occasionally.

Steps to reproduce:

  • Setting the singleton flag in the server definition of the org.eclipse.lsp4e.languageServer extension point to false
  • Open a project file which triggers a LS instance to gets started, then several LS instances gets started for this file.

It looks like a race condition to me, because the (deprecated) org.eclipse.lsp4e.LanguageServerWrapper.getInitializedServer() method gets called from several threads an is not thread safe.
This could be fixed by adding synchronized to the getInitializedServer()method.

All other methods calling org.eclipse.lsp4e.LanguageServerWrapper.start() are tagged synchronized. The start() method itself is synchronized as well, but in this case this seems to be not enough.

This screenshot illustrates the problem (start() has been called twice, added a hit count = 2 to breakpoint in line 251):
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with org.eclipse.lsp4e.LanguageServerWrapper.getInitializedServer() and its callers, then inspect the synchronized start() method. Reproduce with singleton=false and a project file that triggers the language server, checking whether concurrent calls create multiple instances. Done means one server instance is started for the file in the reported race scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.