Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#4410 Tcl hangs or crashes with [fileevent] on too many sockets

obsolete: 8.5.7
open
5
3 days ago
2009-08-19
eee
No

Tcl hangs if I try to use event-driven I/O on more than approximately 1024 channels, and if I use greatly more than that, Tcl crashes. I used ActiveTcl 8.5.6 and an 8.6b1.1 basekit from the teapot. Running on sparc Solaris 10.

gps suggested that the issue has to do with the FD_SETSIZE define of the select() system call, and suggested that the fix involved checking "if ( fd >= FD_SETSIZE)" in tclUnixNotfy.c:Tcl_CreateFileHandler()

# SAMPLE script that will coredump.
# (for a script that merely hangs, change the "3000" to "1100" or smaller)
proc accept {fd host port} {
puts "Got connection: $host:$host:$fd"
fileevent readable $fd [list read-data $fd]
}
proc read-data {fd} {
puts "$fd: [read $fd]"
}
for {set port 1} {$port < 3000} {incr port} {catch {socket -server accept $port} res; puts "$port:$res"}
puts "Now listening."
% vwait forever

Discussion