Fix potential deadlock when triggering project refresh while holding write lock#2595
Open
embeddedt wants to merge 1 commit intominecraft-dev:devfrom
Open
Fix potential deadlock when triggering project refresh while holding write lock#2595embeddedt wants to merge 1 commit intominecraft-dev:devfrom
embeddedt wants to merge 1 commit intominecraft-dev:devfrom
Conversation
Member
|
Since your other PR contained the use of LLMs (nothing wrong with that if you yourself are competent and verify yourself that it's good), could you also let me know if you used LLMs for this PR as well? |
Author
|
I used an LLM to point me in the direction of the locks, but ended up implementing the fix independently (its suggested solution was unnecessarily complex). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The common problem among all the stacktraces I looked at is a deadlock occuring when a thread holding the write lock tries to access the AWT or the write intent lock. My reading of the IntelliJ threading model documentation suggests this can be problematic. Since both of the two cases I found appear to be simple (triggering a project refresh), it seems that the simplest fix is to just queue the refresh call to be run later on the correct thread, independently of any write lock held by the surrounding method.
It will take some time to confirm if this actually fixes the problem, because it is impossible to reproduce reliably, hence why I resorted to stacktrace analysis.
In theory, this fixes #2566, fixes #2519 (there may also be other issue numbers I'm not aware of)