[liboping] Running into some limits in the vicinity of 1024 hosts (exactly 1021+, in fact)

Florian Forster ff at octo.it
Thu May 4 14:33:28 CEST 2017

Hi Jesse,

I'm very sorry for the late reply!

Thank you very much for reporting this issue and in particular thanks
for providing the test case, it proved very useful in tracking this

The culprit was select(2) or rather the FD_SET() macro used to
manipulate a bitmask. This bitmask has a fixed size, FD_SETSIZE, which
is 1024 bits on many systems. Passing a file descriptor that's >=
FD_SETSIZE leads to "undefined behavior", in case of glibc the stack is
corrupted and the test case crashes. "Undefined behavior" means, of
course, that the libc authors are free to do something reasonable like
have an assertion fail or continue without flipping a bit (i.e. without
corrupting the stack), but where's the fun in that?

On the positive side, with commit 4442437[*] your test case no longer
crashes. On the negative side, you will now get the "Too many open
files" error regardless of your ulimit setting. To fix this more
thoroughly, we might look into one of the select(2) alternatives, for
example poll(2), which don't have this limitation.

On Sun, Apr 16, 2017 at 03:55:24AM -0700, Jesse Thompson wrote:
> this reached beyond my gdb depth for example and appears to crash
> within the ping_send function anyway. ;)

Don't feel bad: when the stack is smashed, the program crashes when
*returning* from a function, not when the inappropriate write appears.
The stacktrace printed by gdb is then almost meaningless, because it
tries to interpret the garbage that was written past the end of the
buffer as memory addresses, which usually leads to nothing.

Best regards,

[*] https://github.com/octo/liboping/commit/4442437848f4d07b91c8ae1512b562299a3e6070
Florian octo Forster
Hacker in training
GnuPG: 0x0C705A15
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.verplant.org/pipermail/liboping/attachments/20170504/242e3f5a/attachment.sig>

More information about the liboping mailing list