Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 3129 - Memory leak in GLIBC 2.1 in gethostbyaddr
Summary: Memory leak in GLIBC 2.1 in gethostbyaddr
Keywords:
Status: CLOSED DUPLICATE of bug 3560
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-05-28 18:53 UTC by grumple
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 1999-07-02 20:42:20 UTC


Attachments (Terms of Use)

Description grumple 1999-05-28 18:53:51 UTC
After installing Redhat 6.0 on a production server, I
noticed a problem with syslogd.  syslogd was growing in
memory size proportional to the amount of data received.
This is a box that is doing lots and lots of syslogging from
lots of hosts.

Well after some investigation, and examining of the source
code, I have isolated the bug.  And I am including a sample
program that shows the bug.

It appears that if you call gethostbyaddr, and if the
address is not in /etc/hosts, the gethostbyaddr call leaks
memory.  If the address is in /etc/hosts (which is what we
did to solve the problem for now), it does not leak.  The
program below will call gethostbyaddr 100,000 times, and
then pause so you can take a look at the size of the
process.  Under 5.2 the process does not grow in size.
Under 6.0 the process grows rapidly.

test.c
----------------------------
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void main()
{
        unsigned long n = 0x24b445cf;
        int i;
        struct hostent *hp = 0, *ohp = 0;
        struct sockaddr_in f;
        struct sockaddr_in *f2 = &f;
        f.sin_addr.s_addr = 0xCF45B424;
        f.sin_family = AF_INET;
        for (i=0; i<100000; i++) {
                hp = gethostbyaddr((char *) &n, 4, 2);
                if (ohp != hp)
                    printf("HP CHANGED (%d != %d)\n", ohp,
hp);
                ohp = hp;
                if (!(i % 1000))
                    printf(".");
                fflush(stdout);
        }
        printf("Press <RETURN>... ");
        getc(stdin);
}

Comment 1 Cristian Gafton 1999-07-02 20:42:59 UTC
*** This bug has been marked as a duplicate of 3560 ***


Note You need to log in before you can comment on or make changes to this bug.