Out-of-bounds on fd_set
Ruby uses select() to switch between active file descriptors, and has three fd_set's in struct thread_status_t. However, as far as I can see, no bounds checking is done to see if these are exceeded. Therefore, if you have more than FDSETSIZE files open, ruby can write beyond bounds and strange things happen.
Many Linux systems have FDSETSIZE 1024 and ulimit -n 1024 by default, and so the problem doesn't arise, but the ulimit can be raised by the sysadmin. At this point, ruby is happy to open more than 1024 files, and then crashes.
Should ruby not check for FDSETSIZE and refuse to use files whose fds are beyond this? (This limitation could be removed later if ruby ever moved to poll/epoll/kpoll)
The following code demonstrates the problem. It uses 'connect', because this causes ruby to do a non-blocking connect followed by a select.
srv = 
cli = 
s = TCPServer.new('127.0.0.1',nil)
c = TCPSocket.new('127.0.0.1',s.addr)
srv << s
cli << c
Given 'ulimit -n 2048', for me it falls over like this:
initialize': Socket operation on non-socket - connect(2) (Errno::ENOTSOCK)new'
from ert.rb:4:in `times'
More discussion at http://www.ruby-forum.com/topic/207462