From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 16 11:16:52 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD2D016A4CE for ; Wed, 16 Feb 2005 11:16:52 +0000 (GMT) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 183AE43D4C for ; Wed, 16 Feb 2005 11:16:52 +0000 (GMT) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id 51733530C; Wed, 16 Feb 2005 12:16:50 +0100 (CET) Received: from xps.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 0BE1F5308 for ; Wed, 16 Feb 2005 12:16:26 +0100 (CET) Received: by xps.des.no (Postfix, from userid 1001) id 86DC933C35; Wed, 16 Feb 2005 12:16:26 +0100 (CET) To: hackers@freebsd.org From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) Date: Wed, 16 Feb 2005 12:16:26 +0100 Message-ID: <86mzu4sqk5.fsf@xps.des.no> User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on flood.des.no X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL,FORGED_RCVD_HELO autolearn=disabled version=3.0.1 Subject: memory leak in resolver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2005 11:16:52 -0000 des@xps ~/src/gai% cat gai.c #include #include #include #include int main(void) { struct addrinfo hint, *res; memset(&hint, 0, sizeof(hint)); hint.ai_family =3D AF_INET; hint.ai_socktype =3D SOCK_STREAM; hint.ai_protocol =3D 0; if (getaddrinfo("www.freebsd.org", "http", &hint, &res) =3D=3D 0) freeaddrinfo(res); return (0); } des@xps ~/src/gai% valgrind --leak-check=3Dyes --num-callers=3D8 ./gai =3D=3D44998=3D=3D Memcheck, a memory error detector for x86-linux. =3D=3D44998=3D=3D Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward. =3D=3D44998=3D=3D Using valgrind-2.1.0, a program supervision framework for= x86-linux. =3D=3D44998=3D=3D Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward. =3D=3D44998=3D=3D Estimated CPU clock rate is 3591 MHz =3D=3D44998=3D=3D For more details, rerun with: -v =3D=3D44998=3D=3D =3D=3D44998=3D=3D =3D=3D44998=3D=3D ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 fr= om 0) =3D=3D44998=3D=3D malloc/free: in use at exit: 2328 bytes in 11 blocks. =3D=3D44998=3D=3D malloc/free: 45 allocs, 34 frees, 232569 bytes allocated. =3D=3D44998=3D=3D For counts of detected errors, rerun with: -v =3D=3D44998=3D=3D searching for pointers to 11 not-freed blocks. =3D=3D44998=3D=3D checked 1258740 bytes. =3D=3D44998=3D=3D =3D=3D44998=3D=3D 49 bytes in 5 blocks are definitely lost in loss record 2= of 5 =3D=3D44998=3D=3D at 0x3C033173: malloc (vg_replace_malloc.c:105) =3D=3D44998=3D=3D by 0x3C0D567E: strdup (strdup.c:52) =3D=3D44998=3D=3D by 0x3C0D0403: _nsyylex (nslexer.l:88) =3D=3D44998=3D=3D by 0x3C0CF903: _nsyyparse (y.tab.c:380) =3D=3D44998=3D=3D by 0x3C0D296E: _nsdispatch (nsdispatch.c:353) =3D=3D44998=3D=3D by 0x3C0C6E33: getaddrinfo (getaddrinfo.c:1646) =3D=3D44998=3D=3D by 0x804856C: main (gai.c:15) =3D=3D44998=3D=3D =3D=3D44998=3D=3D LEAK SUMMARY: =3D=3D44998=3D=3D definitely lost: 49 bytes in 5 blocks. =3D=3D44998=3D=3D possibly lost: 0 bytes in 0 blocks. =3D=3D44998=3D=3D still reachable: 2279 bytes in 6 blocks. =3D=3D44998=3D=3D suppressed: 0 bytes in 0 blocks. =3D=3D44998=3D=3D Reachable blocks (those to which a pointer was found) are= not shown. =3D=3D44998=3D=3D To see them, rerun with: --show-reachable=3Dyes The amount of memory leaked seems constant regardless of how many times getaddrinfo() is called, so it's probably from reading resolv.conf. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no