[liboping] liboping assertion failure
Florian Forster
octo at verplant.org
Wed Oct 29 16:25:47 CET 2008
Hi Alex,
On Tue, Oct 21, 2008 at 05:49:40PM +1100, Alex Brooks wrote:
> liboping.c:168: ping_timeval_sub: Assertion `(res->tv_sec > 0) || ((res->tv_sec == 0) && (res->tv_usec > 0))' failed.
oh, that's not good :/
> Any idea why this might be happening?
What's done here is that time is measured using these `struct timeval'.
They have a split up second and sub-second part, so adding to such a
struct or subtracting one from another is not as easy as it could be.
The assertion checks that the time stores in `res' is positive, so I
guess that before that two values were subtracted, possibly to calculate
the time between sending and receiving a packet. The name of the
function is kind of a give-away, too ;)
As just before that assertion, there is a sanity check:
if ((tv1->tv_sec < tv2->tv_sec)
|| ((tv1->tv_sec == tv2->tv_sec)
&& (tv1->tv_usec < tv2->tv_usec)))
return (-1);
The only way I can see this running into the assertion is by having
`tv1' and `tv2' holding the same value. You can try to change the
assertion to:
assert ((res->tv_sec > 0) || ((res->tv_sec == 0) && (res->tv_usec >= 0)));
/* note the `greater than or equal' in `res->tv_usec >= 0' */
Apart from that programming mistake this might be caused by a clock
being set back. Is that some virtual machine you experience this on? Did
you notice any time-specific stuff on any of those machines? To you run
NTPd or ntpdate?
> I'll try harder to get a better bead on it with a core dump,
That's be really useful. Especially the value of the members in `res'
would be interesting.
Regards,
-octo
--
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/liboping/attachments/20081029/33d71e4b/attachment.pgp
More information about the liboping
mailing list