Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Deadlock in LS #178

Open
NiklasRentzCAU opened this issue Feb 26, 2024 · 0 comments
Open

Potential Deadlock in LS #178

NiklasRentzCAU opened this issue Feb 26, 2024 · 0 comments
Labels
bug Something isn't working LSP Affect the klighd language server.

Comments

@NiklasRentzCAU
Copy link
Member

While debugging something, the LS got stuck in a deadlock. This has never happened to me during normal use and probably requires very specific timing/delay in threads so it may not happen in normal use, but here is what can happen:

One thread computes something on the main thread that got put there through the AbstractLanguageServer.addToMainThreadQueue method, i.e. the layoutEngine.layout(newRoot, cause) call in KGraphDiagramServer.doSubmitModel. It therefore holds the lock for the main thread queue (which is a blocking queue) and waits for the diagramState (which will be locked by the KGraphLayoutEngine call.

Another thread is in the KGraphDiagramUpdater.doUpdateDiagram method, calling the prepareModel method after locking the diagramState lock. This method then calls the AbstractLanguageServer.addToMainThreadQueue method, trying to access the main thread queue lock, thus resulting in a circular dependency and a deadlock.

A first idea: We probably should never hold the diagramState lock when trying to access the main thread queue lock, thus fixing any calls to that and documenting this restriction.

@NiklasRentzCAU NiklasRentzCAU added bug Something isn't working LSP Affect the klighd language server. labels Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LSP Affect the klighd language server.
Projects
None yet
Development

No branches or pull requests

1 participant