Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
race condition between channel.fileno() and closing channel when using select.select() with paramiko channels. #537
full working code exposing this problem (assumes passwordless ssh to localhost):
Output of above program (interrupted after hang)
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).
added a commit
Feb 11, 2016
referenced this issue
Jun 9, 2016
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