[Linux-HA] [patch] clock_t wrapped around causingfalse resourcestart failure

Lars Ellenberg lars.ellenberg at linbit.com
Thu Jul 2 06:16:59 MDT 2009

On Thu, Jul 02, 2009 at 11:00:08AM +0200, Dejan Muhamedagic wrote:
> >         if (cmp_longclock(lnow, append->nexttime) >= 0)
> > assuming that nexttime was set correctly, and lnow is correct, too,
> > and further assuming your clock_t is only 32 bit,
> > longclock_t is defined as unsigned long long,
> > and that thing becomes:
> > 
> >         if ((unsigned long long)(lnow) >= (unsigned long long)(append->nexttime))
> > 
> > which exactly does _NOT_ care for wrap around :(
> > 
> > 
> > example:
> > 	say, you start with a _large_ lnow (e.g. the equivalent of "-15
> But you can't start with large lnow. lnow is 64-bit and you can't
> get that far into the future.

Hm. Right.

Then maybe something else is wrong, like some wrong typecast?
int i = -300000;
unsigned long long l_wrong = i;
unsigned long long l_right = (unsigned long long)(unsigned int)i;

l_wrong is now "very far" into the future,
and my patch would fix the comparison of that.

whereas l_right is just below 2<<32, and will compare fine in 64 bit
wide unsigned long long, with the existing code.

Simon: can you help to track this down?  Which exact "platform" is this
on, heartbeat version, configure and compiler flags...
You could also try to start this in a VM, and try to reproduce?

Or shall we just ignore this for now?

: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.

More information about the Linux-HA mailing list