From owner-freebsd-bugs Wed Oct 2 15: 4:13 2002 Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 41A4337B401; Wed, 2 Oct 2002 15:04:11 -0700 (PDT) Received: from postal1.lbl.gov (postal1.lbl.gov [128.3.7.82]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9569A43E65; Wed, 2 Oct 2002 15:04:10 -0700 (PDT) (envelope-from j_guojun@lbl.gov) Received: from postal1.lbl.gov (localhost [127.0.0.1]) by postal1.lbl.gov (8.11.2/8.11.2) with ESMTP id g92M49N13006; Wed, 2 Oct 2002 15:04:09 -0700 (PDT) Received: from lbl.gov (gracie.lbl.gov [131.243.2.175]) by postal1.lbl.gov (8.11.2/8.11.2) with ESMTP id g92M49q12995; Wed, 2 Oct 2002 15:04:09 -0700 (PDT) Message-ID: <3D9B6D58.517BE8A4@lbl.gov> Date: Wed, 02 Oct 2002 15:04:09 -0700 From: "Jin Guojun [DSD]" X-Mailer: Mozilla 4.76 [en] (X11; U; FreeBSD 4.5-RELEASE i386) X-Accept-Language: zh, zh-CN, en MIME-Version: 1.0 To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: kern/43599: Balloc did not check mallocated pointer in libc/stdlib/strtod.c References: <200210022140.g92Le18Z084749@freefall.freebsd.org> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org FreeBSD-gnats-submit@FreeBSD.org wrote: > >Category: kern > >Responsible: freebsd-bugs > >Synopsis: Balloc did not check mallocated pointer in libc/stdlib/strtod.c > >Arrival-Date: Wed Oct 02 14:40:01 PDT 2002 # define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock); The reason that causes malloc a piece of small memory failure is the malloc THREAD_LOCK() failure. One printf() in a regular session is allocating memory, and timeout (SIGALARM) starts another printf() which causes overtaking the malloc() and returns 0 (NULL): void * malloc(size_t size) { register void *r; THREAD_LOCK(); malloc_func = " in malloc():"; if (malloc_active++) { wrtwarning("recursive call\n"); malloc_active--; THREAD_UNLOCK(); return (0); } ... } In libc (not libc_r), THREAD_LOCK() may not exist, so above if {...} block sounds like big under this situation. Program terminated with signal 11, Segmentation fault. #0 0x80676f2 in Balloc (k=1) at /usr/src/lib/libc/../libc/stdlib/strtod.c:387 (xxgdb) up #1 0x80684e1 in d2b (d=0.18469299376010895, e=0xbfbfe81c, bits=0xbfbfe828) at /usr/src/lib/libc/../libc/stdlib/strtod.c:1011 (xxgdb) where #0 0x80676f2 in Balloc (k=1) at /usr/src/lib/libc/../libc/stdlib/strtod.c:387 #1 0x80684e1 in d2b (d=0.18469299376010895, e=0xbfbfe81c, bits=0xbfbfe828) at /usr/src/lib/libc/../libc/stdlib/strtod.c:1011 #2 0x8069a6e in __dtoa (d=0.18469299376010895, mode=3, ndigits=4, decpt=0xbfbfeae0, sign=0xbfbfe874, rve=0xbfbfe868, resultp=0xbfbfeacc) at /usr/src/lib/libc/../libc/stdlib/strtod.c:1930 #3 0x8066c98 in cvt (value=0.18469299376010895, ndigits=4, flags=256, sign=0xbfbfeaf2 "", decpt=0xbfbfeae0, ch=102, length=0xbfbfead8, dtoaresultp=0xbfbfeacc) at /usr/src/lib/libc/../libc/stdio/vfprintf.c:1222 #4 0x80647bd in vfprintf (fp=0x8086338, fmt0=0x807e475 "%d %.4f sec. %s%s\n", ap=0xbfbfeb68 "¼ë¿¿àä\a\b\220ë¿¿lñ¿¿æò¿¿") at /usr/src/lib/libc/../libc/stdio/vfprintf.c:603 #5 0x8063988 in fprintf (fp=0x8086338, fmt=0x807e475 "%d %.4f sec. %s%s\n") at /usr/src/lib/libc/../libc/stdio/fprintf.c:70 #6 0x804844f in timeout () at ../netest.c:191 #7 0xbfbfffac in ?? () #8 0x806cb88 in malloc (size=28) at /usr/src/lib/libc/../libc/stdlib/malloc.c:1076 #9 0x80676e4 in Balloc (k=1) at /usr/src/lib/libc/../libc/stdlib/strtod.c:386 #10 0x80684e1 in d2b (d=0.17467300593852997, e=0xbfbfef2c, bits=0xbfbfef38) at /usr/src/lib/libc/../libc/stdlib/strtod.c:1011 #11 0x8069a6e in __dtoa (d=0.17467300593852997, mode=3, ndigits=4, decpt=0xbfbff1f0, sign=0xbfbfef84, rve=0xbfbfef78, resultp=0xbfbff1dc) at /usr/src/lib/libc/../libc/stdlib/strtod.c:1930 #12 0x8066c98 in cvt (value=0.17467300593852997, ndigits=4, flags=256, sign=0xbfbff202 "", decpt=0xbfbff1f0, ch=102, length=0xbfbff1e8, dtoaresultp=0xbfbff1dc) at /usr/src/lib/libc/../libc/stdio/vfprintf.c:1222 #13 0x80647bd in vfprintf (fp=0x8086338, fmt0=0x807e475 "%d %.4f sec. %s%s\n", ap=0xbfbff278 "Ìò¿¿àä\a\bN\226\004\b\n") at /usr/src/lib/libc/../libc/stdio/vfprintf.c:603 #14 0x8063988 in fprintf (fp=0x8086338, fmt=0x807e475 "%d %.4f sec. %s%s\n") at /usr/src/lib/libc/../libc/stdio/fprintf.c:70 #15 0x804974c in main (argc=10, argv=0xbfbff370) at ../netest.c:191 #16 0x8048135 in _start () -- ------------ Jin Guojun ----------- v --- j_guojun@lbl.gov --- Distributed Systems Department http://www.itg.lbl.gov/~jin M/S 50B-2239 Ph#:(510) 486-7531 Fax: 486-6363 Lawrence Berkeley National Laboratory, Berkeley, CA 94720 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message