[Bug dynamic-link/16805] dynamic library not getting reinitialized on multiple calls to dlopen()
romain.geissler at amadeus dot com
sourceware-bugzilla@sourceware.org
Fri Jun 16 15:41:00 GMT 2017
https://sourceware.org/bugzilla/show_bug.cgi?id=16805
Romain Geissler <romain.geissler at amadeus dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |romain.geissler at amadeus dot com
--- Comment #8 from Romain Geissler <romain.geissler at amadeus dot com> ---
Hi,
Sorry for digging into this old bug report, but we have just noticed we were
also affected after a glibc/gcc upgrade.
Jason Merrill has described the rational behind GNU unique symbols in
https://www.sourceware.org/ml/libc-alpha/2002-05/msg00222.html, and indeed the
introduction of this GNU extension makes sense.
Yet what I don't understand is the piece of code that does flag a dlopen'ed
library as NODELETE if one relocation is resolve into this library. In current
trunk it is here:
https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;h=3d2369dbf2b7ca219eaf80a820e2a8e1329fbf50;hb=92bd70fb85bce57ac47ba5d8af008736832c955a#l332
In this old 2002 post, Jason mentions solution #1 and #2, both of them being
needed to work well.
#1 is "Always prefer the last weak definition if no strong definition is
seen.". From what I see here:
https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;h=3d2369dbf2b7ca219eaf80a820e2a8e1329fbf50;hb=92bd70fb85bce57ac47ba5d8af008736832c955a#l526
this is already the case in the trunk for years (at least this is the comment
says, I am not sure this is what is really implemented).
#2 is "If a DSO A has two unrelated dependencies B and C which both define (and
use) the same weak symbol, add C to the dependency list of this loaded
copy of B."
Isn't this the point of "add_dependency" called here
https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-lookup.c;h=3d2369dbf2b7ca219eaf80a820e2a8e1329fbf50;hb=92bd70fb85bce57ac47ba5d8af008736832c955a#l929
after the call to "do_lookup_x" which handles unique symbols in a specific way
?
My point is, unique symbols do create some bindings between libraries that
normally should not be bound together. I am fine with that. However if I do
unload all these dlopen'ed library, I would expect all dynamically dependencies
added between the two RTLD_LOCAL object to be removed, and eventually all the
libraries to be fully unloaded (with static destructor called). I am fine with
"dlclose" not closing the library if another dlopened library has some symbols
resolved into the first one, but then a second call to "dlclose" on the second
library should unload both libraries.
So am I right thinking that marking libraries where unique relocation are
resolved to as NODELETE is wrong ? All the mechanism is already there to
properly handle the closing of libraries at the right time thanks to
"add_dependency", isn't it ?
Cheers,
Romain
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list