Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 156835 - nc enters infinite loop when pipe closes.
Summary: nc enters infinite loop when pipe closes.
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: nc
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Radek Vokal
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-05-04 16:18 UTC by David Woodhouse
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version: 1.78-2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-05-11 10:41:41 UTC


Attachments (Terms of Use)
strace of offending nc. (deleted)
2005-05-11 10:24 UTC, David Woodhouse
no flags Details

Description David Woodhouse 2005-05-04 16:18:56 UTC
nc is being used as a ssh ProxyCommand. When SSH is finished with it it ought to
die gracefully. It doesn't; it ends up eating CPU...

poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1

Comment 1 Radek Vokal 2005-05-05 10:17:27 UTC
David, may I have some steps how to reproduce this? 

Comment 2 David Woodhouse 2005-05-05 10:34:14 UTC
I'd imagine this should trigger it for you fairly easily...

cat >> ~/.ssh/config <<EOF
Host *
  ProxyCommand nc %h %p
EOF


Comment 3 David Woodhouse 2005-05-10 17:52:25 UTC
Any progress? If you added that to your SSH configuration you ought to be seeing
a lot of this now...

Comment 4 Radek Vokal 2005-05-11 10:09:59 UTC
Nope, I still don't see this. Running nc host 22 gives no errors and if I try
your steps, I see that nc is running while sshed and after closing the ssh
session nc ends corectly .. 

Comment 6 David Woodhouse 2005-05-11 10:19:27 UTC
#0  0x0ff43cb8 in poll () from /lib/libc.so.6
#1  0x10001928 in readwrite (nfd=3) at netcat.c:615
#2  0x10002278 in main (argc=Variable "argc" is not available.
) at netcat.c:375


Comment 7 David Woodhouse 2005-05-11 10:24:33 UTC
Created attachment 114240 [details]
strace of offending nc.

Comment 8 Radek Vokal 2005-05-11 10:37:13 UTC
The else branch looks really strange to me. If you're calling exec on nc, should
this create a whole new shell for nc? That's maybe why it's still open after
closing ssh session. 

Comment 9 David Woodhouse 2005-05-11 10:43:53 UTC
fsh isn't a shell. It's a faster version of ssh, which re-uses a single
authenticated connection for running multiple commands. 

The logic is "if we're within the internal network use netcat, else ssh to the
bastion host and run netcat there". It's the former case which is failing. 

I don't actually know why it's not 'exec nc' in the first case, which does also
work around the problem -- but fixing netcat to react appropriately to POLLHUP
is also appropriate. 


Note You need to log in before you can comment on or make changes to this bug.