RTLD_GLOBAL again (was Re: kdeutils/kregexpeditor/test)

Malte Starostik malte at kde.org
Sun Apr 21 00:32:58 BST 2002


Am Sunday 21 April 2002 01:00 schrieb Lubos Lunak:
> On Saturday 20 April 2002 23:42, Martijn Klingens wrote:
> > On Saturday 20 April 2002 21:37, Michael Matz wrote:
> > I think it is a good idea to promote the use of namespaces. If we start
> > now then maybe by the time of KDE 4.0 we can decide whether we can start
> > loading all libs with RTLD_GLOBAL. Till that time qt_cast is the way to
> > go IMO.
>
>  Here I originally wanted to say that KDE4.0 is too long and such, but now
> after thinking about, if the only difference will be
> RTLD_LOCAL<->RTLD_GLOBAL and qt_cast<->dynamic_cast, then fine. This in
> fact means that we will be slowly moving to state when we will be
> pretending that we actually use RTLD_GLOBAL, just we won't yet.
I just found another issue: deginer will crash on startup when kdewidgets.so 
is installed. This is what happens:
designer loads the plugins from the plugin directory. First it tries them as 
EditorPlugin. Since kdewidgets.so isn't such a thing, but a QWidgetPlugin, it 
unloads the lib again (trying as QWidgetPlugin happens later). This unloading 
causes a crash.
I stripped anything from kdewidgets.cpp that needs kdeui and linked only 
against libkdecore, then at least the unload works (of course kdewidgets 
isn't of any use then). As soon as libkdeui is linked in, the crash appears.
The program below reproduces the crash (sorry for the hardcoded path). When 
libqt-mt is _not_ linked in, the crash only happens on exit, as soon as it is 
linked, it happens on the dlclose() call.

#include <dlfcn.h>
#include <iostream>

int main( int argc, char* argv[] )
{
    using std::cerr;
    using std::endl;
    cerr << "Loading kdewidgets.so..." << endl;
    void* lib = dlopen( 
"/usr/local/kde/lib/kde3/plugins/designer/kdewidgets.so", RTLD_LAZY );
    cerr << "Done. Unloading..." << endl;
    dlclose( lib );
    cerr << "Done. Exiting..." << endl;
}

When RTLD_GLOBAL is added to the dlopen() options, the crash goes away. I 
don't think this bt is really accurate, but anyway:
#0  0x00000000 in ?? ()
#1  0x412aac8f in __static_initialization_and_destruction_0 
(__initialize_p=1094307840,
    __priority=1073821528) at ../../../kdelibs/kdecore/kdebug.cpp:168
#2  0x412aace8 in _GLOBAL__D__Z6perrorR10kdbgstream () at 
../../../kdelibs/kdecore/kdebug.cpp:70
#3  0x412975b7 in __do_global_dtors_aux () from 
/usr/local/kde/lib/libkdecore.so.4
#4  0x4138c519 in _fini () from /usr/local/kde/lib/libkdecore.so.4
#5  0x408db773 in _dl_close () from /lib/libc.so.6
#6  0x408db460 in _dl_close () from /lib/libc.so.6
#7  0x40021efa in dlclose () from /lib/libdl.so.2
#8  0x4000ada3 in _dl_catch_error (objname=0x804ad10, errstring=0x804ad14,
    operate=0x40021ee0 <dlclose+60>, args=0x80a2928) at dl-error.c:152
#9  0x4002221b in dlerror () from /lib/libdl.so.2
#10 0x40021ec4 in dlclose () from /lib/libdl.so.2
#11 0x08048a60 in main (argc=1, argv=0xbffff714) at foo.cpp:23
#12 0x407dc2c7 in __libc_start_main () from /lib/libc.so.6

so basically, KDE widget support doesn't work in designer with gcc 3.1 as long 
as Qt opens plugins with RTLD_GLOBAL :-(((
-- 
Malte Starostik
PGP: 1024D/D2F3C787 [C138 2121 FAF3 410A 1C2A  27CD 5431 7745 D2F3 C787]





More information about the kde-core-devel mailing list