Bug 4657

Summary: memory leak in gethostbyname() when (not) using NIS+
Product: [Retired] Red Hat Linux Reporter: antonyn
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0CC: dbaron
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-08-23 14:31:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description antonyn 1999-08-23 02:45:04 UTC
Hello,

I am running RH6.0 + updates on an x86 machine.  This box is
networked and uses NIS to sync accounts across our network.

The problem arises when code like the following is run on a
RH6 machine with the default NIS installation:

#include <stdio.h>
#include <netdb.h>
int main() {
   while (1) {
      struct hostent* pHostEnt = NULL ;
      pHostEnt = gethostbyname("www.redhat.com");
   }
  return 0 ;
}

Note that using gethostbyname_r has the same problem (I did
a search on deja.com, and Theodore Tso mentioned that using
the standard gethostbyname is prone to memory leaks.)

Running this program and watching it in top will show that
the process will continually eat memory until it severely
bogs down the machine.  The problem is glibc-related, but it
is actaully triggered with RH's default NIS setup.  The
"hosts:" entry in /etc/nsswitch.conf has 'nisplus' listed
before 'dns' - I'm guessing the leak starts here, as
switching the order (ie, having 'dns' listed before
'nisplus' on a network setup that queries a valid DNS
server) will fix the problem.

--Ant

Comment 1 antonyn 1999-08-23 02:53:59 UTC
Hello, I just found this URL on deja.com which sheds more light.
Perhaps it's time for a new glibc RPM release?

http://x46.deja.com/getdoc.xp?server=x46&AN=479412353&CONTEXT=935376493.1108344895&hitnum=2

Comment 2 antonyn 1999-08-23 02:55:59 UTC
One last note - my friend runs the latest Mandrake which includes this
version of glibc; he's a huge Mandrake advocate.  We can't have RH be
behind Mandrake in bugfixes now, can we? ;)

Comment 3 Jeff Johnson 1999-08-23 14:31:59 UTC
Memory leaks in NIS code are fixed in the Raw Hide glibc.