Bug 4570 - RPC client memory leak
Summary: RPC client memory leak
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-08-17 13:42 UTC by Aric
Modified: 2008-05-01 15:37 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 1999-08-18 15:47:39 UTC


Attachments (Terms of Use)

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.


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