Date: Wed, 16 Feb 2005 12:16:26 +0100 From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) To: hackers@freebsd.org Subject: memory leak in resolver Message-ID: <86mzu4sqk5.fsf@xps.des.no>
next in thread | raw e-mail | index | archive | help
des@xps ~/src/gai% cat gai.c
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86mzu4sqk5.fsf>
