Skip to content

A stop can deadlock with a file rename when a document it disconnects has unsent changes #1902

Closed

Description

@lagergren

A language server's stop disconnects its open documents, and each disconnection holds documentsLock while it disposes the document's synchronizer. With changes of the document not sent yet, the synchronizer sends them first, and on a thread without read access it reads the document in a non-blocking read action, which waits while a write action is pending or running. The rename or move of a file disconnects its document under documentsLock in its write action. The stop then waits for the write action, and the write action for documentsLock, which the stop holds, so the UI thread hangs.

How it happens

It needs a stop on a thread without read access while a document has unsent changes, and a rename or move at that moment, so it's rare. It was found by reading the code in the review of #1891 (thread), and hasn't been reproduced.

Possible direction

Don't wait for a read action while holding documentsLock: take the document out of the maps under the lock, and dispose its synchronizer, which sends the pending changes and didClose, after releasing the lock, keeping the didClose ahead of a later didOpen of the same URI.

Activity

  1. lagergren commented on Nov 9, 2026

    @lagergren
    CollaboratorAuthor

    This is a regression of this release cycle: 0.21.0 doesn't have it. There, disconnect disposed the synchronizer without holding documentsLock, and sendDidChangeEvents sent the pending changes without a read action. Our #1707 (2680f3b1) put the dispose under documentsLock, and our #1698 (ff834ce1) made the pending changes wait for a read action, both merged 2026-10-19; #1891 then made every rename that the listener handles take the lock. So 0.30.0 would ship a freeze that 0.21.0 doesn't have.

    @angelozerr, could you put it on the 0.30.0 milestone? I'm preparing the fix.

  2. added
    bug
    on Nov 9, 2026
  3. added this to the 0.30.0 milestone on Nov 9, 2026
  4. moved this to In Progress in Java Toolingon Nov 9, 2026
  5. angelozerr commented on Nov 9, 2026

    @angelozerr
    Contributor

    This is a regression of this release cycle: 0.21.0 doesn't have it. There, disconnect disposed the synchronizer without holding documentsLock, and sendDidChangeEvents sent the pending changes without a read action. Our #1707 (2680f3b1) put the dispose under documentsLock, and our #1698 (ff834ce1) made the pending changes wait for a read action, both merged 2026-10-19; #1891 then made every rename that the listener handles take the lock. So 0.30.0 would ship a freeze that 0.21.0 doesn't have.

    @angelozerr, could you put it on the 0.30.0 milestone? I'm preparing the fix.

    done

  6. moved this from In Progress to Done in Java Toolingon Nov 9, 2026
  7. added a commit that references this issue on Nov 9, 2026
    0e630ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions