Re: dlclose in fl_wrapper

Alejandro Mery <[email protected]>
Newsgroups gmane.linux.distributions.rock.devel
Message-ID <[email protected]>
Clifford Wolf wrote:
> Hi,
> 
> On Wed, Jan 19, 2005 at 03:12:12PM +0100, [email protected] wrote:
> 
>>Open Patch: 2005011915121217030 [by mnemoc]                  + mnemoc
>>
>>Alejandro Mery:
>>        * fixed fl_wrapper to _not_ dlclose
>>(libc_handle), from T2 Project.
> 
> 
> is there any rationale about this patch? the dlopen is a few lines above
> the dlcose and since the dynamic loader manages usage counters, removing
> the dlclose would cause a memory leak..

simple, and i'm impressed you have never noticed. libc_handle is 
_static_ and if != 0 it's asumed to be opened. so if you dlclose it you 
dlsym a _closed_ handle.

static void * libc_handle = 0;

if (!libc_handle) libc_handle=dlopen("libc.so.6", RTLD_LAZY);
if (!libc_handle) {
         printf("fl_wrapper.so: Can't dlopen libc: %s\n", dlerror());
         abort();
}

dlclose(libc_handle);

what's worse open a closed handle, or keep it opened. at least removing 
this close i finished a full target based on uclibc which seem to be 
more exhaustive than glibc to dlclose.

Alejandro
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.