Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-12-24
10:20 • Closed ticket [1847064fff]: Event loop goes CPU bound when select() invalid fd</... artifact: 2a9d73cdd8 user: sf-robot
2007-12-10
05:26 • Pending ticket [1847064fff]. artifact: 62ae514ed9 user: hobbs
2007-12-09
00:01 • New ticket [1847064fff]. artifact: 92fff95689 user: dnew

Event loop goes CPU bound when select() invalid fd

Closed / Out of Date1847064fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-12-09 00:01:39
I had a bug in a program that created outgoing sockets and didn't close them when they failed. Basically
  set x [socket -async machine.next.door 12345]
  puts $x $somedata
  flush $x ; #This threw, caught by bgerror
  close $x

Eventually, however, I wound up with a large number of socket channels that were open but disconnected.

Now, here's the funny part: After a while, the process would go compute bound. Using the lovely advice from CLT, I could "strace -p $pid" and see what it's doing.

It's stuck in a tight loop with select() throwing errors because the socket number is out of range. 

I can't seem to reproduce it in a trivial program. The code I actually use does set and unset the blocking flag at different parts of the protocol, which may have something to do with it.

I wrote a little program that just opens a new async socket every second with [after], and it worked fine up past 256 sockets, whereas the big code was bombing out after 32 or 64, so I'm not sure what's different there. It might be a little harder to find than I thought. 

info patchlevel give 8.4.14, and this is SuSE Linux 10.2 running the penultimate kernel (blah blah.5) 

Feel free to contact me if I can help track this further.
hobbsplain2007-12-10 05:26:07
Logged In: YES 
user_id=72656
Originator: NO

2006-11-27  Kevin Kenny  <[email protected]>

* unix/tclUnixChan.c (TclUnixWaitForFile):
* tests/event.test (event-14.*): Corrected a bug where
TclUnixWaitForFile would present select() with the wrong mask on an
LP64 machine if a fd number exceeds 32. Thanks to Jean-Luc Fontaine
for reporting and diagnosing [Bug 1602208]

Please retest with head or latest 8.4.
sf-robotplain2007-12-24 10:20:04
Logged In: YES 
user_id=1312539
Originator: NO

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.