Opened 14 years ago

Last modified 13 years ago

#103 closed defect

wxDllLoader::loadLibrary, dlopen called w/o RTLD_GLOBAL

Reported by: anonymous Owned by: vadz
Priority: normal Milestone:
Component: Version:
Keywords: Cc: vadz, jice_vwaty_com, mbrubeck
Blocked By: Blocking:
Patch: no

Description

This might be considered a bug or a feature request; not
sure...
What happens is that when HAVE_DLOPEN is defined,
wxDllOpen(lib) expands as:

dlopen(lib.fn_str(), RTLD_NOW/*RTLD_LAZY*/)

This is fine in many cases but not all: if more than
one lib is loaded, and if one lib has undefined
symbols that are supposed to be resolved by another
library previously loaded, this resolution will not be
performed, unless the first library was loaded as follows:

dlopen(firstlib, RTLD_NOW|RTLD_GLOBAL)

In other words, if the symbol table of the first library
was merged in the executable's symbol table.
In many such cases, libraries reference each other explicitly and so dlopen loads automatically all the other
libraries required, and performs symbol resolution at
that time. However, I know of at least one library that
depends on another without mentioning it: libssl.so
needs libcrypto.so. As a result, an application such
as Mahogany fails to load libssl.so, eventhough it takes
care of loading libcrypto beforehand.

May be setting the RTLD_GLOBAL flag in all cases would have
known adverse effects that I am not aware of, in which case
my proposal is to add a member function such as
LoadLibraryGlobal() to the wxDllLoader class.

J-C (jice@…)

Change History (4)

comment:1 Changed 14 years ago by jice_vwaty_com

To the bug tracker administrator:

Sorry for the "nobody" author; I created an account half-way through filling the report.

my user id is jice_vwaty_com

comment:2 Changed 14 years ago by jice_vwaty_com

To the bug tracker administrator:

Sorry for the "nobody" author; I created an account half-way through filling the report.

my user id is jice_vwaty_com

comment:3 Changed 14 years ago by vadz

ok, added RTLD_GLOBAL - let's see now if anybody complains

comment:4 Changed 13 years ago by mbrubeck

May be setting the RTLD_GLOBAL flag in all cases would
have known adverse effects that I am not aware of, in
which case my proposal is to add a member function such
as LoadLibraryGlobal() to the wxDllLoader class.

I have an example of an adverse effect from RTLD_GLOBAL. In
the Audacity sound editor we use wxDllLoader to load
third-party plugins. When two of these plugins happen to
declare global variables with the same name and type,
RTLD_GLOBAL linking causes one plugin to write over the
other's variable. This actually happened to us, and caused
a segfault bug.

It is important for us to use RTLD_LOCAL scoping. There
should be some way to control the dlopen() flags used by
wxDllLoader on Unix.

Note: See TracTickets for help on using tickets.