Port-sparc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Overflow during subtraction



On Sat, Oct 27, 2012 at 09:25:17PM -0700, AGC wrote:
> Hi everyone,
> 
> I've got an intermittent overflow problem occurring in ntpd's code. 
> It's calculating the difference between two 64 bit longs.  The problem 
> area seems to be in (or possibly the calling function) 
> refclock_process_f() in ntp_refclock.c.
> 
> The calculations result in a value of exactly 2**31 (2147483648) for an 
> offset which causes ntpd to panic and bomb out (thinking something has 
> gone wrong with the system clock).

I'd guess at one of:
1) a simple logic error
2) the 64bit quanitity being updated in another process/interrupt
   between the reads of the high and low parts
3) some in memory location being read twice, but the code expects
   it not to change between the reads.

I'd save the inputs and outputs each time the code runs.
On error print this times values and last times values.
(And maybe re-read the inputs again!)

That will probably be illiminative enough to locate the problem.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index