Fix race condition between Channel.close() and other channel send met…#1137
Open
yieldi wants to merge 1 commit intoparamiko:mainfrom
Open
Fix race condition between Channel.close() and other channel send met…#1137yieldi wants to merge 1 commit intoparamiko:mainfrom
yieldi wants to merge 1 commit intoparamiko:mainfrom
Conversation
This was referenced Aug 23, 2021
ploxiln
added a commit
to ploxiln/paramiko-ng
that referenced
this pull request
Nov 26, 2021
While the channel tracks its state for generating messages under its own lock, it needs to release that lock before calling the transport method to send a message, which uses the transport's lock. Messages could be generated under the correct conditions and in the correct order, but then sent in a different order, if two different threads are calling channel methods. This was made much more likely by the recent addition of ChannelStdinFile (in paramiko-ng 2.8.0) which calls shutdown_write() automatically when closed. So, for now, protect only EOF to fix the immediate regression, and reduce code churn. There is already a mess of state checking of dubious robustness, e.g. the open_only() decorator ... This problem was well described in paramiko#1115 and this solution is heavily inspired by paramiko#1137 so: Co-Authored-By: Ryan <rrasti@google.com>
ploxiln
added a commit
to ploxiln/paramiko-ng
that referenced
this pull request
Nov 26, 2021
While the channel tracks its state for generating messages under its own lock, it needs to release that lock before calling the transport method to send a message, which uses the transport's lock. Messages could be generated under the correct conditions and in the correct order, but then sent in a different order, if two different threads are calling channel methods. (We need to release the channel lock to avoid deadlock during re-keying according to commit 305f5e0.) This was made much more likely by the recent addition of ChannelStdinFile (in paramiko-ng 2.8.0) which calls shutdown_write() automatically when closed. So, for now, protect only EOF to fix the immediate regression, and reduce code churn. There is already a mess of state checking of dubious robustness, e.g. the open_only() decorator ... This problem was well described in paramiko#1115 and this solution is heavily inspired by paramiko#1137 so: Co-Authored-By: Ryan <rrasti@google.com>
Contributor
|
Labeling as |
AlonMarko
pushed a commit
to AlonMarko/paramiko
that referenced
this pull request
Nov 4, 2025
…d lock (refs paramiko#1115; inspired by paramiko#1137, paramiko-ng#101)
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.
…hods.
This is a fix for #1115 .