Bug 4570

Summary: RPC client memory leak
Product: [Retired] Red Hat Linux Reporter: Aric <aric>
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-08-18 15:47:39 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 Aric 1999-08-17 13:42:12 UTC
When I write a simple RPC client/server application, the
client has a memory leak of 336 bytes per
clnt_create()/clnt_destroy() pair.  I am using glibc-2.1.1-6
and glibc-devel-2.1.1-6.

The program does not exhibit this behavior on a Solaris
machine, nor does it exhibit this behavior on an older
RedHat 5.2 machine (with glibc-2.0.7-29).  If I compile with
dynamic linking on RedHat 5.2 and run it on RedHat 6.0, the
leak occurs.  If I link statically on RedHat 5.2 and run it
on RedHat 6.0, the leak does not occur.  Looks like a glibc
problem.

The output is shown at the end for the glibc-2.1.1-6 (RedHat
6.0) version.

Here is the buggy.x rpcgen file that I'm using:
-----------------8<------------------------------
program BUGGY_IFACE {
    version BUGGY_IFACE_VER {
        long test_long(long) = 1;
    } = 1;
} = 0x3123456;
-------------------8<----------------------------
The server is the default one produced with 'rpcgen -a', but
the client I am using is as follows:
-------------------8<------------------------------
#include "buggy.h"
#include <malloc.h>

static void
display_used_memory(void)
{
    struct mallinfo mi;

    mi = mallinfo();
    printf("Used memory: %u\n", mi.usmblks + mi.uordblks);
}

void
buggy_iface_1(char *host)
{
    CLIENT *clnt;

    printf("Before clnt_create: ");
    display_used_memory();

    clnt = clnt_create (host, BUGGY_IFACE, BUGGY_IFACE_VER,
"udp");
    if (clnt == NULL) {
        clnt_pcreateerror (host);
        exit (1);
    }

    printf("Before clnt_destroy: ");
    display_used_memory();

    clnt_destroy (clnt);

    printf("After clnt_destroy: ");
    display_used_memory();
}


int
main (int argc, char *argv[])
{
    while(1) {
        buggy_iface_1 ("localhost");
        sleep(1);
    }
    exit (0);
}
-------------------------8<------------------------
Here is the output:
Before clnt_create: Used memory: 0
Before clnt_destroy: Used memory: 21860
After clnt_destroy: Used memory: 4140
Before clnt_create: Used memory: 4140
Before clnt_destroy: Used memory: 22196
After clnt_destroy: Used memory: 4476
Before clnt_create: Used memory: 4476
Before clnt_destroy: Used memory: 22532
After clnt_destroy: Used memory: 4812
Before clnt_create: Used memory: 4812
Before clnt_destroy: Used memory: 22868
After clnt_destroy: Used memory: 5148
Before clnt_create: Used memory: 5148
Before clnt_destroy: Used memory: 23204
After clnt_destroy: Used memory: 5484
Before clnt_create: Used memory: 5484
Before clnt_destroy: Used memory: 23540
After clnt_destroy: Used memory: 5820
...

Comment 1 Jeff Johnson 1999-08-18 15:47:59 UTC
Upgrade to the Raw Hide glibc packages. Your test program does not
leak on my ultrasparc with glibc-2.1.2-5.