[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: What is wrong with this program?



[Ulrich, I've Cc:d you since this is a problem with the libdl-2.0.7.so
in my Red Hat 5.1 system which seems to be part of the glibc package.]

Mihai,

Phew.  I thought for a little while you had found a bug in libpam! 8^]

Mihai Ibanescu writes:
> On Thu, 1 Oct 1998, Andrew Morgan wrote:
> > I'll play with this and get back to you, but first could I have some
> > more info....

> 	One more info: the bug is in SUN's Pam API too. The history is
> like this:

I can't speak for Sun's dlopen/dlclose and/or their libpam (anyone got
the source?), so the bug there may well be some other problem.

However, I'm basically convinced that this is a dlopen/dlclose issue.
Here is another program for you to try.  Please note, there is no PAM
involved here and the shared library chosen for the dlopen call does
not seem to be important:

==============
/*
 * memory leak in libdl.1.7.14 and /lib/libdl.so.2
 * (under libc and glibc).
 */

#include <dlfcn.h>

main()
{
    int i=10000;

    while (i-->0) {
	void *x = dlopen("/lib/libtermcap.so.2", RTLD_GLOBAL);
	printf("x=%p\n", x);
	dlclose(x);
    }
}

/*
 * compile with:  cc -o test test.c -ldl
 */
==============

Running this against either of the above libdl's (with libc5 and glibc
respectively) seems to exhibit the memory leak.  The process grows as
witnessed by running top.

> - Yesterday I've checked it myself. Discovered that indeed there is a
> memory leak. Started to RTFM. Nothing obviously wrong.
> 
> - Made the small program I've sent on the list.
> 
> 	It should be reproducible.

It was and thanks for posting this...

Anyone have any idea what libdl is doing?  Know how to fix it?

Cheers

Andrew



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []