NetBSD, llround, pivot, testing

Hal Murray hmurray at megapathdsl.net
Sat May 6 07:51:27 UTC 2017


An interesting tangle...

In case anybody has missed it, one of our tests doesn't work on NetBSD.  It's 
issue 264
  https://gitlab.com/NTPsec/ntpsec/issues/264

I tracked that back to a bug in llround() on NetBSD.  It can't handle numbers 
that turn into 53 bit integers (or bigger). It's only used by dtolfp to 
convert a double to a l_fp.

First, thanks to all who helped with the testing package.  This would have 
been a real pain to track down if the only symptom was "doesn't work right".

If I'm doing the math right...  53 bits of l_fp is 21 bits of seconds.  
That's 12 days.

So I rebooted a Raspberry Pi running NetBSD.  Nothing interesting.  I assume 
it's setting the clock from the file system.  So I set the clock back a 
month.  It says it's doing what looks reasonable, but nothing happens.

15 Apr 20:43:06 ntpd[729]: 0.0.0.0 c61c 0c clock_step +1728058.862503 s
15 Apr 20:43:07 ntpd[729]: 0.0.0.0 c615 05 clock_sync

15 Apr 20:48:48 ntpd[729]: 0.0.0.0 c61c 0c clock_step +1728057.999922 s
15 Apr 20:53:56 ntpd[729]: 0.0.0.0 c61c 0c clock_step +1728057.000011 s
15 Apr 21:00:19 ntpd[729]: 0.0.0.0 c61c 0c clock_step +1728056.999994 s
15 Apr 21:09:43 ntpd[729]: 0.0.0.0 c61c 0c clock_step +1728055.999962 s
15 Apr 21:23:28 ntpd[729]: 0.0.0.0 c61c 0c clock_step +1728054.999837 s

After patching dtolfp to be:
        return (l_fp)(int64_t)(ldexp(d, 32));
15 Apr 20:47:31 ntpd[4038]: 0.0.0.0 c61c 0c clock_step +1737343.005830 s
 5 May 23:23:14 ntpd[4038]: 0.0.0.0 c615 05 clock_sync

---------

Looks like it took two recent changes to turn into an actual bug.

c0973bb27e231356290bb51964175da4a404ca4e
Author: Eric S. Raymond <esr at thyrsus.com>
Date:   Mon Apr 17 12:15:02 2017 -0400
    Restore cross-era interoperability via pivoting timestamps on build data.

That restored using dtolfp in step_systime()
so large steps won't work on NetBSD.


commit 194cbd22565ae49dde0d70b9d47033e50edb097d
Author: Gary E. Miller <gem at rellim.com>
Date:   Thu Apr 6 19:09:04 2017 -0700
    Fix 120 warnings, and round on conversion from double to l_fp.

-       return (l_fp)((int64_t)ldexp(d, 32));
+       return (l_fp)(llround(ldexp(d, 32)));


-- 
These are my opinions.  I hate spam.





More information about the devel mailing list