Library unloading (Re: [PATCH] auto-completing URLs on Ctrl-Enter)
Thiago Macieira
thiago at kde.org
Sat Feb 4 16:09:11 GMT 2006
Martijn Klingens wrote:
>On Saturday 04 February 2006 13:23, Thiago Macieira wrote:
>> - you have no objects created there that could be using a non-global
>> symbol (libraries are loaded without global binding)
>>
>I'm not sure what you mean with the last of your 3 points. To take the
> example of Kopete back when I wanted this (about 3 years ago), there
> was libkopete and there was the MSN plugin, and of course the main app
> with kdelibs and friends.
This is mostly a corner case, and a twist of the second point (no objects
of classes defined on the module).
Imagine the KAllInline class, where everything is inline. Imagine that
this class has at least one virtual function (which means it has a
vtable). And imagine that this class's .h file is from kdecore, so it's
an installed header.
If the library was compiled with -fvisibility-inline-hidden, the vtable
and virtual calls will resolve to within the library. So if you have an
object of this class, their virtual tables will differ, depending on
which library the object was created on.
Now, note that this kind of object is special because you can't even
dynamic_cast<> it or throw it across libraries, or your program will
crash.
>But now your last item. You said "you have no objects created there
> [...]", but the way I interpret that this cannot be true anyway by the
> time the dlclose happens, since with proper memory management all
> objects are deleted by then. Perhaps not really needed for the normal
> app termination case, but absolutely required if you want to design
> plugins for hot unloading and reloading, so I'm not sure I see the
> relation with symbols being global or non-global. Could you explain?
The point is that modules aren't loaded RTLD_GLOBAL. That means they
resolve names first locally, then globally. So if the same name is
defined twice (such as the case I illustrated above), we violate the rule
of C++ that there is only one instance of any given one symbol.
Then again, everything is a twist of the first point: you cannot keep a
pointer to any memory address being unmapped. This includes virtual table
addresses.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
4. And æfter se scieppend ingelogode, he wrát "cenn", ac eala! se
rihtendgesamnung andswarode "cenn: ne wát hú cennan 'eall'. Ástynt."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20060204/2f81594a/attachment.sig>
More information about the kfm-devel
mailing list