1345! 8o
Selected quotes from
man select:
FD_SETSIZE [...] is normally at least equal to the maximum number of descriptors supported by the system
BUGS
The default size FD_SETSIZE (currently 1024) is somewhat smaller than the current kernel limit to the number of open files. However, in order to accommodate programs which might potentially use a larger number of open files with select, it is possible to increase this size within a program by providing a larger definition of FD_SETSIZE before the inclusion of .
Supposedly,
ulimit -n (under bash) or
limit descriptors (under tcsh) displays the maximum number of open file descriptors. I get 256. However, these may only apply to the shell and programs it starts. May not apply to programs started from the Finder or from gdb.
On the other hand, I can do this:
(gdb) print (int) getdtablesize() # get descriptor table size
$1 = 10240
This seems to correspond to:
% sysctl kern.maxfilesperproc
kern.maxfilesperproc = 10240
Here's another line of inquiry:
(gdb) call (rlimit*)malloc(sizeof(rlimit))
$1 = (rlimit *) 0x2b0e100
(gdb) call (int) getrlimit(8, $1) # RLIMIT_NOFILE == 8
$2 = 0
(gdb) print *$1
$3 = {
rlim_cur = 10240,
rlim_max = 10240
}
(gdb) call (void)free($1)
I'm not entirely sure whose responsibility it is to avoid this problem. I suppose wxWidgets could do:
struct rlimit foo;
getrlimit(RLIMIT_NOFILE, &foo);
if (foo.rlim_max > FD_SETSIZE)
{
foo.rlim_cur = FD_SETSIZE;
foo.rlim_max = FD_SETSIZE;
setrlimit(RLIMIT_NOFILE, &foo);
}
at initialization to make sure that socket descriptors don't exceed FD_SETSIZE;
HipHop, here's something for you to test:
$ gdb /Path/to/amuled
(gdb) break main
(gdb) run
(gdb) call (rlimit*)malloc(sizeof(rlimit))
(gdb) call (int) getrlimit(8, $1) # RLIMIT_NOFILE == 8
(gdb) print *$1 # I'm curious if the output from this matches what I got
(gdb) set *$1 = { 1024, 1024 }
(gdb) call (int) setrlimit(8, $1)
(gdb) call (void) free($1)
(gdb) cont
If I'm right, then amuled will run just fine without crashing. Of course, this is a test by absence of evidence, but your crashes are so reliable that I think we can consider the mystery solved if amuled runs a good long while.