public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/15048] New: getaddrinfo() leaks memory when /etc/nssswitch.conf is not present.
@ 2013-01-22 14:42 jiji.vinitha at gmail dot com
2013-01-22 14:43 ` [Bug network/15048] " jiji.vinitha at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: jiji.vinitha at gmail dot com @ 2013-01-22 14:42 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15048
Bug #: 15048
Summary: getaddrinfo() leaks memory when /etc/nssswitch.conf is
not present.
Product: glibc
Version: 2.11
Status: NEW
Severity: normal
Priority: P2
Component: network
AssignedTo: unassigned@sourceware.org
ReportedBy: jiji.vinitha@gmail.com
Classification: Unclassified
Created attachment 6829
--> http://sourceware.org/bugzilla/attachment.cgi?id=6829
patch which fixes the leak
Hi,
Found in glibc-2.11.2 on arm-*-linux-gnueabi target.
The scenario:
When
* /etc/nsswitch.conf is not existing
* gethostbyname() has not been called
* dns server is reachable
* "localhost.localdomain" is not resisted to dns
In the above scenario, getaddrinfo("localhost.localdomain"); is leaking
memory.
The testcase to reproduce this issue
[nsstest.c]
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
struct addrinfo *res;
int cnt = 2500;
#if 0
if (gethostbyname("localhost.localdomain") == 0) {
}
#endif
for( i = 0; i < cnt; i++ ) {
if( getaddrinfo("localhost.localdomain", NULL, NULL, &res ) == 0 ){
freeaddrinfo(res);
}
write(1, ".", 1);
}
write(1, "done\n", 5);
while(1){sleep(62);}
return 0;
}
How to reproduce the leak
# strace -e open ./nsstest
...
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory) <- cause of leak
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory)
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory)
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory)
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory)
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory)
.open("/etc/nsswitch.conf", O_RDONLY) = -1 ENOENT (No such file or
directory)
...
RSS is increasing as shown below while executed the binary
# ./nsstest
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................^Z
[1]+ Stopped ./nsstest
# ps
PID TTY TIME CMD
167 pts/0 00:00:00 bash
284 pts/0 00:00:00 nsstest
285 pts/0 00:00:00 ps
# ps -p 284 u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 284 0.9 0.5 1960 668 pts/0 T 00:29 0:00 ./nsstest
# fg
./nsstest
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^Z
[1]+ Stopped ./nsstest
# ps -p 284 u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 284 1.3 0.6 2088 768 pts/0 T 00:29 0:00 ./nsstest
# fg
./nsstest
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^Z
[1]+ Stopped ./nsstest
# ps -p 284 u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 284 1.1 0.7 2216 912 pts/0 T 00:29 0:00 ./nsstest
#
The attached patch solved this issue in glibc-2.11.2.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-30 8:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-22 14:42 [Bug network/15048] New: getaddrinfo() leaks memory when /etc/nssswitch.conf is not present jiji.vinitha at gmail dot com
2013-01-22 14:43 ` [Bug network/15048] " jiji.vinitha at gmail dot com
2013-04-15 12:25 ` siddhesh at redhat dot com
2013-04-15 12:31 ` siddhesh at redhat dot com
2013-09-10 5:51 ` allan at archlinux dot org
2013-09-30 8:32 ` schwab@linux-m68k.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).