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
race condition between channel.fileno() and closing channel when using select.select() with paramiko channels. #537
Comments
full working code exposing this problem (assumes passwordless ssh to localhost):
|
Output of above program (interrupted after hang)
|
Can you please try recreating this on Paramiko 1.15.x? A lot has changed since 1.10.x. |
The bug is easily reproducible with above program on paramiko 1.5.12 (under docker in order not to mess my environment, ubuntu 14.04).
|
I prepared a simple reproduction test for this issue, along with a proposed fix. |
With the code in this ticket, I cannot recreate the hang on OS X 10.10; but I can recreate it on Debian 8. @rusek's commit's test, executed without his fix in place, fails on both platforms. And his fix makes the test pass on both platforms, as well as causing the OP's example to pass on Debian. So that's good. Re: why the fix works, threading is not my forte but I think staring at things long enough made sense...would appreciate a sanity check of the below before I merge:
|
The error case is actually quite simple, and does not involve recreating OS pipes. It is enough that client receives either MSG_CHANNEL_EOF or MSG_CHANNEL_CLOSE from remote site before calling select for the first time (where pipe is created). The scenario from the ticket works roughly as follows:
After giving it some thought, I now see that As for the locking added to |
Thanks! That makes sense; when I reread my notes, it does jive - the creation of the new OS level pipe is incidental, it's having any pipe - original or new - enter the "always You're probably right about 👍 on the locking, I suspected it was more of a cleanup-while-there change, but I'm fine with that & agree that consistency is a virtue here. |
FTR, I cherry-picked @rusek's change back to the 1.16 branch and above, and will close this once I push. |
The following code
may lead to deadlock because a pipe created internally in channel.fileno() can be created after channel is closed().
python 2.7.6
paramiko 1.10.1
Linux Mint 17
The text was updated successfully, but these errors were encountered: