GH-909: Fix KexOutputHandler self-deadlock on inline write failure during shutdown#910
Merged
tomaswolf merged 1 commit intoJul 23, 2026
Conversation
Member
|
Can you please put the PR description minus the "Fixes #909" line into the commit message? Good commit messages are important, especially in OSS. For future contributors and maintainers it is very helpful if the commit messages explain the reasoning behind a change as it makes it much easier to figure out the history via |
zimmermq
force-pushed
the
GH-909-kexoutputhandler-deadlock
branch
from
July 23, 2026 08:58
599727f to
36f6faf
Compare
Author
|
Done, I've moved the explanation into the commit message (subject + body) and force-pushed. Thanks for the nudge; fully agree the reasoning belongs in git rather than only in the PR. |
…ure during shutdown When a write started under the read lock in writeOrEnqueue() fails inline, the session close re-enters KexOutputHandler.shutdown()→updateState(), which tries to take the write lock on the same thread — an illegal read-to-write upgrade that self-deadlocks. Fix: in shutdown(), when the current thread already holds the read lock (getReadHoldCount() > 0), update the state without acquiring the write lock. The read lock already excludes writers, so it stays consistent; KEX write-ordering is unchanged. Includes a deterministic regression test (hangs without the fix, passes with it).
zimmermq
force-pushed
the
GH-909-kexoutputhandler-deadlock
branch
from
July 23, 2026 09:17
36f6faf to
da979e1
Compare
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.
Fixes #909.
When a write started under the read lock in
writeOrEnqueue()fails inline, the session close re-enters KexOutputHandler.shutdown()→updateState()`, which tries to take the write lock on the same thread — an illegal read-to-write upgrade that self-deadlocks.Fix: in
shutdown(), when the current thread already holds the read lock (getReadHoldCount() > 0), update the state without acquiring the write lock. The read lock already excludes writers, so it stays consistent; KEX write-ordering is unchanged.Includes a deterministic regression test (hangs without the fix, passes with it).