Port-sparc archive

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

Re: ntpd wedged by libc?



On Sun, Mar 11, 2012 at 03:14, Christos Zoulas <christos%zoulas.com@localhost> 
wrote:
> On Mar 10,  2:56pm, agcarver+netbsd%acarver.net@localhost (AGC) wrote:
> | Well, that didn't take long:
> |
> |
> | (gdb) bt
> | #0  0x103c3430 in .umul () from /usr/lib/libc.so.12
> | #1  0x103b58fc in __pow5mult_D2A () from /usr/lib/libc.so.12
> | #2  0x103b5adc in __muldi3 () from /usr/lib/libc.so.12
> | #3  0x103b5494 in __mult_D2A () from /usr/lib/libc.so.12
> | #4  0x103b5728 in __pow5mult_D2A () from /usr/lib/libc.so.12
> | #5  0x103a8138 in __dtoa () from /usr/lib/libc.so.12
> | #6  0x00067a04 in fmtflt (str=0xefffe450 " 109.76 97.75 98.77 97.79
> | 103.00 97.72 98.15", len=0xefffe364,
> |      size=184, fvalue=-4.2612301185727119, width=0, precision=2,
> | flags=0, overflow=0xefffe360) at snprintf.c:1152
> | #7  0x0006898c in rpl_vsnprintf (str=0xefffe450 " 109.76 97.75 98.77
> | 97.79 103.00 97.72 98.15", size=184,
> |      format=<value optimized out>, args=0xefffe438) at snprintf.c:851
> | #8  0x00068de4 in rpl_snprintf (str=0xefffe450 " 109.76 97.75 98.77
> | 97.79 103.00 97.72 98.15", size=184,
> |      format=0x8a260 " %.2f") at snprintf.c:1583
> | #9  0x000252a0 in ctl_putarray (tag=<value optimized out>, arr=0xb3128,
> | start=2) at ntp_control.c:1673
> | #10 0x000262e8 in ctl_putpeer (id=30, p=0xb2fa0) at ntp_control.c:2506
> | #11 0x0002b068 in read_variables (rbufp=0x10528000, restrict_mask=0) at
> | ntp_control.c:3012
> | #12 0x00028a44 in process_control (rbufp=0x10528000, restrict_mask=0) at
> | ntp_control.c:1123
> | #13 0x00038744 in receive (rbufp=0x10528000) at ntp_proto.c:432
> | #14 0x00023410 in ntpdmain (argc=0, argv=0xefffebdc) at ntpd.c:1069
> | #15 0x000138a4 in ___start ()
> | #16 0x000137dc in _start ()
> |
> | The printf_dota.log file is about 2.2 MB located here:
> |
> | http://acarver.net/ntpd/printf_dtoa.log
>
> Hmm, does not seem to leak for me. Here's how I tested it:

Thanks for trying.   A question and a suggestion below.

> #include <stdio.h>
> #include <string.h>
> #include <errno.h>
> #include <sys/endian.h>
>
> int
> main(int argc, char *argv[])
> {
>        union {
>                unsigned long long ull;
>                double d;
>        } u;
>        char line[128];
>
>        FILE *fp = fopen("/dev/null", "w");
>
>        while (fgets(line, sizeof(line), stdin)) {
>                char *p = strchr(line, '\n');
>                if (p)
>                        *p = '\0';
>                errno = 0;
>                u.ull = be64toh(strtoull(line, &p, 16));

Assuming you're testing this on sparc32, is it necessary to byte-swap
with be64toh()?  Did you verify, for example, that the last value in
the log interpreted as a double is -4.2612301185727119?

>                if (errno)
>                        err(1, "line=%s", line);
>                else if (p == line || *p)
>                        errx(1, "line=%s", line);
>                fprintf(fp, "%g", u.d);

You might be able to tickle it by changing this to:

fprintf(fp, "%g %.2f %.3f", u.d, u.d, u.d);

>        }
>        fclose(fp);
>        return 0;
> }
>

Thanks,
Dave Hart


Home | Main Index | Thread Index | Old Index