libtool-patches
[Top][All Lists]
Advanced

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

Re: Fix ltdl memory handling


From: Gary V. Vaughan
Subject: Re: Fix ltdl memory handling
Date: Thu, 02 Sep 2004 14:35:49 +0100
User-agent: Mozilla Thunderbird 0.7 (X11/20040615)

Hi Ralf!

Ralf Wildenhues wrote:
> Besides the memory leaks fixed with this patch, try_dlopen allocates one
> *phandle which does not get freed eventually (try a current valgrind on
> mdemo_static for example).  The logic is too involved for me to see a
> simple fix without understanding all the code.

You have found your way into the tangled innards of libltdl.  Here be dragons!

I don't think anyone understands this code anymore; for the last year or so
I've been gradually picking at the seams near the edges and trying to tease
out everything else in the hope that what remains will be smaller and easier
to follow.  I'll have a look with valgrind the next time I am on a Linux box,
but don't be surprised if we have to relegate it to the TODO list until
libltdl has been untangled some more...

> Regarding this patch:  In conformance with slist.[ch] comments, I went
> without changing the semantics of slist_remove although I would have
> found that a more natural way (i.e., to free(stale) from within
> slist_remove).

I wrote the original slist for an m4 prepatch where it chained together lists
of structures that had a next pointer as their first field.  The version that
found its way into libltdl was from before the box/unbox semantics had
settled, but I haven't been updating it.  In light of your patch I've merged
in the latest version and adjusted the callers, which fixes the bugs you have
found I think.

>  Patch below leaves an unpleasant cast-away-const in
> lt_dlloader_remove.

And fixed this too.

> 2004-09-01 Ralf Wildenhues <address@hidden>
> 
>         libltdl/slist.c (slist_new): Handle malloc failure gracefully.

libtool--devo--1.0--patch-153

>         libltdl/lt_dlloader.c (lt_dlloader_add): Likewise for caller.

libtool--devo--1.0--patch-154

>         (loader_cmp): Return node instead of userdata..
>         (lt_dlloader_remove) ..so we can free it here.  Remove unused
>         variable.  (lt_dlloader_find): Adjust for new loader_cmp
>         semantics.
>         libltdl/ltdl.c (lt_dlexit): While cleaning up, consider that the
>         global `loaders' list is changed by `lt_dlloader_remove' while
>         cleaning up, so target of local variable `loader' is invalidated.
>         This is necessitated by the changes in lt_dlloader_remove.

libtool--devo--1.0--patch-155

>         (try_dlopen): Fix memleak.

libtool--devo--1.0--patch-156

Thankyou once again for your thought provoking patches.

Cheers,
        Gary.
-- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]