Bug 4897 - rdesktop gets into a loop over the control socket
Summary: rdesktop gets into a loop over the control socket
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: | rdesktop (deprecated) (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.2.0
Assignee: Henrik Andersson
URL:
Keywords: astrand_tester, prosaic
Depends on:
Blocks:
 
Reported: 2013-11-13 10:29 CET by Pierre Ossman
Modified: 2014-05-05 14:51 CEST (History)
0 users

See Also:
Acceptance Criteria:


Attachments

Description Pierre Ossman cendio 2013-11-13 10:29:46 CET
We introduced a control socket in rdesktop in order to do session sharing. Igge managed to get rdesktop into a tight loop, eating 100% CPU, and the socket is involved:


 8253 johig     20   0  557m 7032 1656 R 100.3  0.1  51:17.83 rdesktop                                                                                                                                             

[root@castro ~]# strace -p 8253
Process 8253 attached - interrupt to quit
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
select(10, [3 4 5 6 9], [], NULL, {0, 200000}) = 2 (in [6 9], left {0, 199997})
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
select(10, [3 4 5 6 9], [], NULL, {0, 200000}) = 2 (in [6 9], left {0, 199996})
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
select(10, [3 4 5 6 9], [], NULL, {0, 200000}) = 2 (in [6 9], left {0, 199996})
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
select(10, [3 4 5 6 9], [], NULL, {0, 200000}) = 2 (in [6 9], left {0, 199996})
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
select(10, [3 4 5 6 9], [], NULL, {0, 200000}) = 2 (in [6 9], left {0, 199996})
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
select(10, [3 4 5 6 9], [], NULL, {0, 200000}) = 2 (in [6 9], left {0, 199996})
recvfrom(6, "", 1024, 0, NULL, NULL)    = 0
recvfrom(9, "", 1024, 0, NULL, NULL)    = 0
recvfrom(4, 0x2799cc4, 4096, 0, 0, 0)   = -1 EAGAIN (Resource temporarily unavailable)
^CProcess 8253 detached
[root@castro ~]# ll /proc/8253/fd
total 0
lr-x------. 1 johig johig 64 Nov 13 10:23 0 -> pipe:[2784234325]
l-wx------. 1 johig johig 64 Nov 13 10:23 1 -> /var/opt/thinlinc/sessions/johig/1/xinit.log
l-wx------. 1 johig johig 64 Nov 13 10:23 2 -> pipe:[2784234326]
lrwx------. 1 johig johig 64 Nov 13 10:23 3 -> socket:[2784234332]
lrwx------. 1 johig johig 64 Nov 13 10:23 4 -> socket:[2784234333]
lrwx------. 1 johig johig 64 Nov 13 10:23 5 -> socket:[2616342855]
lrwx------. 1 johig johig 64 Nov 13 10:22 6 -> socket:[2616342202]
lr-x------. 1 johig johig 64 Nov 13 10:23 7 -> pipe:[2784234295]
l-wx------. 1 johig johig 64 Nov 13 10:23 8 -> pipe:[2784234295]
lrwx------. 1 johig johig 64 Nov 13 10:22 9 -> socket:[2616342223]
[root@castro ~]# ll /proc/8253/fd^C
[root@castro ~]# netstat -ne |grep 2616342202
unix  2      [ ]         STREAM     CONNECTED     2616342202 /home/johig/.local/share/rdesktop/ctrl/2e1aeb3a90302808c9e0bd303f20140c86d976f6.ctl
[root@castro ~]# netstat -ne |grep 2616342223
unix  2      [ ]         STREAM     CONNECTED     2616342223 /home/johig/.local/share/rdesktop/ctrl/2e1aeb3a90302808c9e0bd303f20140c86d976f6.ctl


Since recvfrom() returns 0, I guess the socket is simply closed and we do not handle this common case?
Comment 1 Pierre Ossman cendio 2013-11-13 10:30:02 CET
Also, why are there two open connections?
Comment 2 Henrik Andersson cendio 2013-11-14 13:31:57 CET
I found the cause (a creepy typo), when ctrl client disconnects the ctrl socket is not cleaned up from ctrl clients list.

Upstream commit 1749 fixes this issue.
Comment 3 Henrik Andersson cendio 2013-12-12 16:30:24 CET
Vendordrop of upstream in commit 28197
Comment 4 Peter Åstrand cendio 2014-05-05 14:51:09 CEST
Difficult to reproduce, but code makes sense, and basic functionality works on 2008R2.

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