3 ms·
Hmmm the article links to another article called "select is fundamentally broken" but even that article fails to note, that select has a nasty gotcha. Many (mos
by StillBored 9y ago
Hmmm the article links to another article called "select is fundamentally broken" but even that article fails to note, that select has a nasty gotcha. Many (most?) examples (http://www.tutorialspoint.com/unix_system_calls/_newselect.htm http://www.tutorialspoint.com/unix_system_calls/_newselect.h...) simply use 'fd_set' and the FD_* macros.
So, struct fd_set is a fixed size structure, and the fd, passed to the macros (or kernel) has a max fd value that it can support. So its quite possible your application has a fd > FD_SETSIZE even if you don't think your using a lot of fds (libraries and such can drive up the value of fd quite easily).
The result is random buffer smashing, both by userspace via the FD_XXX macros as well as the kernel, which doesn't have any knowledge beyond the nfds (which is the largest fd, not the number of fd's) its given. That is why you use poll()..
I can't tell you how many times I've had to fix that bug in programs that appear to work fine for $SHORTTIME, but fail when running for $LONGTIME.