Description of problem: A friend of mine discovered that freeaddrinfo does not release all the memory that was previously alocated Version-Release number of selected component (if applicable): any glibc (tested in RHEL 4U3 - glibc 2.3.6 and gentoo - glibc 2.4) How reproducible: Always Steps to Reproduce: 1. compile the following program: #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> int main() { struct sockaddr addr; struct addrinfo hints, *ai_res; struct protoent *pe; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_CANONNAME; hints.ai_family = PF_UNSPEC; ::getaddrinfo("127.0.0.1", "smtp", &hints, &ai_res); ::freeaddrinfo(ai_res); return 0; } 2. g++ test.c -o test 3. run valgrind --tool=memcheck -v --leak-check=yes ./test Actual results: ==9371== 10 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==9371== at 0x1B903984: malloc (vg_replace_malloc.c:131) ==9371== by 0x2FCB9F: strdup (in /lib/tls/libc-2.3.6.so) ==9371== by 0x342C9D: gaih_inet (in /lib/tls/libc-2.3.6.so) ==9371== by 0x344690: getaddrinfo (in /lib/tls/libc-2.3.6.so) ==9371== ==9371== LEAK SUMMARY: ==9371== definitely lost: 10 bytes in 1 blocks. ==9371== possibly lost: 0 bytes in 0 blocks. ==9371== still reachable: 0 bytes in 0 blocks. ==9371== suppressed: 0 bytes in 0 blocks. Expected results: No "lost" bytes Additional info: http://pastebin.com/626735
Should be fixed upstream: http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&r1=1.10076&r2=1.10077 http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/posix/getaddrinfo.c.diff?cvsroot=glibc&r1=1.93&r2=1.94
This issue is on Red Hat Engineering's list of planned work items for the upcoming Red Hat Enterprise Linux 4.4 release. Engineering resources have been assigned and barring unforeseen circumstances, Red Hat intends to include this item in the 4.4 release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2006-0510.html