Port-sparc archive

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

Re: ntpd wedged by libc?



In article 
<CAGN_6pY9GoO6jOKSGuKJnDF_ZFRom9HaVZhUHBjMEn=5aBUZ4A%mail.gmail.com@localhost>,
David Brownlee  <abs%netbsd.org@localhost> wrote:
>On 7 February 2012 23:13, AGC <agcarver+netbsd%acarver.net@localhost> wrote:
>Apologies for asking a potentially stupid question:
>
>Assuming this is just a specific toxic value or values, rather than
>some strange state caused by a sequence of events, is it not possible
>to run with a version of libc which logs every value passed to dtoa(),
>or just run a (quite long running :) test program which tests every
>bit pattern?

Nope this is just a memory leak. Convert enough floating point values
and you run out of memory [the missing Bfree(b)]. This should be pulled
up to 5.

christos

Index: misc.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gdtoa/misc.c,v
retrieving revision 1.7
retrieving revision 1.11
diff -u -r1.7 -r1.11
--- misc.c      21 Mar 2011 04:52:09 -0000      1.7
+++ misc.c      21 Nov 2011 09:46:19 -0000      1.11
@@ -76,8 +76,10 @@
                else
                        rv = (Bigint*)MALLOC(len*sizeof(double));
 #endif
-               if (rv == NULL)
+               if (rv == NULL) {
+                       FREE_DTOA_LOCK(0);
                        return NULL;
+               }
                rv->k = k;
                rv->maxwds = x;
                }
@@ -415,8 +417,10 @@
                ACQUIRE_DTOA_LOCK(1);
                if (!(p5 = p5s)) {
                        p5 = p5s = i2b(625);
-                       if (p5 == NULL)
+                       if (p5 == NULL) {
+                               FREE_DTOA_LOCK(1);
                                return NULL;
+                       }
                        p5->next = 0;
                        }
                FREE_DTOA_LOCK(1);
@@ -432,6 +436,7 @@
                        b1 = mult(b, p5);
                        if (b1 == NULL)
                                return NULL;
+                       Bfree(b);
                        b = b1;
                        }
                if (!(k = (unsigned int)k >> 1))
@@ -441,8 +446,10 @@
                        ACQUIRE_DTOA_LOCK(1);
                        if (!(p51 = p5->next)) {
                                p51 = p5->next = mult(p5,p5);
-                               if (p51 == NULL)
+                               if (p51 == NULL) {
+                                       FREE_DTOA_LOCK(1);
                                        return NULL;
+                               }
                                p51->next = 0;
                                }
                        FREE_DTOA_LOCK(1);
christos




Home | Main Index | Thread Index | Old Index