Red Hat Bugzilla – Bug 187087
memory leak in glibc
Last modified: 2007-11-30 17:07:24 EST
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)
Steps to Reproduce:
1. compile the following program:
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);
2. g++ test.c -o test
3. run valgrind --tool=memcheck -v --leak-check=yes ./test
==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== 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.
No "lost" bytes
Additional info: http://pastebin.com/626735
Should be fixed upstream:
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.