This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Python: subprocess running rsync causes broken socket in telnetlib


On Fri, Nov 12, 2010 at 16:19, David Antliff wrote:
>
> I'm reporting a problem I see on Cygwin because I do not see the same
> behaviour on Ubuntu Linux - both systems are running Python 2.6.5.
>
> I have a script that opens a long-term telnet connection (telnetlib)
> to a remote host. There is an object called Telnet().socket that is
> created and represents an active socket connection to the remote host,
> once the right telnetlib calls are made.
>
> Then the script uses subprocess to do something else (the line is
> actually longer than this but I've simplified it to the most basic
> version that exhibits the problem):
>
> ? ?process = subprocess.Popen("rsync", stdout=subprocess.PIPE)
>
> On Cygwin 1.7.7, this does something nasty to the completely unrelated
> yet existing telnetlib socket so that any further attempts to read or
> write from this socket raise an exception:
>
> ?File "/usr/lib/python2.6/telnetlib.py", line 280, in write
> ? ?self.sock.sendall(buffer)
> ?File "<string>", line 1, in sendall
> socket.error: [Errno 32] Broken pipe
>
> On Linux, this doesn't happen at all.
>
> I've tried a few other programs via subprocess like "cat" and "ssh"
> but they don't seem to cause this problem - only "rsync" does so far.
> There may be others but I haven't found them.
>
> If anyone is prepared to look into this I have attached a small python
> script (bug.py) that demonstrates the problem. The error returned in
> this case is "113: Software caused connection abort", but the end
> result is the same - the socket is broken by the call to subprocess &
> rsync:
>
> $ python bug.py
> ('telnet', '220 mx.google.com ESMTP w42sm3212723wfh.15\r\n')
> ('ssh', 0, 'OpenSSH_5.6p1, OpenSSL 0.9.8o 01 Jun 2010\n')
> ('telnet', '250-mx.google.com at your service, [202.27.34.1]\r\n')
> ('rsync', 0, 'rsync ?version 3.0.7 ?protocol version 30\nCopyright (C) 1996')
> Traceback (most recent call last):
> ?File "bug.py", line 38, in <module>
> ? ?print("telnet", t.read_eager())
> ?File "/usr/lib/python2.6/telnetlib.py", line 370, in read_eager
> ? ?self.fill_rawq()
> ?File "/usr/lib/python2.6/telnetlib.py", line 516, in fill_rawq
> ? ?buf = self.sock.recv(50)
> socket.error: [Errno 113] Software caused connection abort
>
> If you edit the script and set 'crash' to False, you'll see that the
> script completes without error:
>
> $ python bug.py
> ('telnet', '220 mx.google.com ESMTP i16sm3108013ibl.0\r\n')
> ('ssh', 0, 'OpenSSH_5.6p1, OpenSSL 0.9.8o 01 Jun 2010\n')
> ('telnet', '250-mx.google.com at your service, [202.27.34.1]\r\n')
> ('telnet', '250-SIZE 35651584\r\n250-8BITMIME\r\n250-STARTTLS\r\n250')
>
> And on Linux:
>
> $ python bug.py
> ('telnet', '220 mx.google.com ESMTP i16sm3106343ibl.18\r\n')
> ('ssh', 0, 'OpenSSH_5.3p1 Debian-3ubuntu4, OpenSSL 0.9.8k 25 Mar 2009\n')
> ('telnet', '250-mx.google.com at your service, [202.27.34.1]\r\n')
> ('rsync', 0, 'rsync ?version 3.0.7 ?protocol version 30\nCopyright (C) 1996')
> ('telnet', '250-SIZE 35651584\r\n250-8BITMIME\r\n250-STARTTLS\r\n250')


This bug is still present in Cygwin 1.7.8:
$ uname -a
CYGWIN_NT-5.1 pc770 1.7.8(0.236/5/3) 2011-03-01 09:36 i686 Cygwin

rsync is still version 3.0.7.

What additional information may be required? Let me know and I'll
assist with debugging, especially as the implications of this bug may
be quite serious (leaking file descriptors?)

-- David.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]