bug-libtool
[Top][All Lists]
Advanced

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

Re: multiple load/unload of modules crashes


From: Gary V. Vaughan
Subject: Re: multiple load/unload of modules crashes
Date: Fri, 15 Dec 2000 17:54:01 +0000
User-agent: Mutt/1.2.5i

On Wed, Dec 13, 2000 at 02:19:16PM -0600, Tod Milam wrote:
> My app loads 4 modules, unloads them, then attempts to load another. 
> For each module loaded it calls lt_dlinit() and for each unload it calls
> lt_dlexit(). 

This is a very unusual use of the ltdl API, though I have to say that,
technically, it is perfectly legal.  However by doing things the way
you have, the additional lt_dlinit() calls (beyond the first) and
lt_dlexit() calls (except the last) have the overhead of a function
call and maintenance of a reference counter to no real advantage.
What's worse is that you go through all the machinery to shut down
libltdl after unloading your ``last'' module, only to reinitialise the
whole lot again when you come to loading a further module later on.

Unless the layout of your client code makes it difficult to do
otherwise, you can save all of this overhead by making a single call to
lt_dlinit() near the start of main() (or better yet somewhere in your
module initialisation that doesn't fire if you load no modules at all,
but is guaranteed to be called before any other ltdl API call), and
lt_dlexit() just before the program quits (unless you didn't need to
run lt_dlinit() for some reason).

> I tracked it down to the loaders static variable not being reset to 0
> after all of the loaders had been removed.  The following patch fixed my
> problem:

I agree with your diagnosis, and have applied your fix to the HEAD and
multi-language branches of the repository.  Thanks for the excellent
detailed report!

Cheers,
        Gary.
-- 
  ___              _   ___   __              _         mailto: address@hidden
 / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___       address@hidden 
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
 \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
home page:  /___/                      /___/                  gpg public key:
http://www.oranda.demon.co.uk           http://www.oranda.demon.co.uk/key.asc



reply via email to

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