kdelibs/libltdl brokenness..

Dominique Devriese dominique.devriese at student.kuleuven.ac.be
Mon Jul 21 21:54:18 BST 2003


this mail is quite long, skip to "EXECUTIVE SUMMARY + CONCLUSION"
below, if you're not interested in the details ;)

I'm working on the embedded python in my app ( kdeedu/kig ), and I
have recently been hit by kdelibs' libltdl copy's brokenness.  The
problem basically is that lt_dlopen does not use the RTLD_GLOBAL flag,
even though the docs say [1] that it is always used, because it states
that "unresolved symbols in a loaded module are resolved using ... and
previously dlopened modules."  This means that those previous modules
have to have been opened with RTLD_GLOBAL, which is not the case.

This leads to problems when in my KPart application, the part library
is dlopened by KTrader ( using the above libltdl bug, implementation,
see above ).  The kpart library is dynamically linked against
libpython.so, and exports it symbols, because it was compiled with
"-Wl,-E".  But then, when I try to do "import math" from the embedded
python, it tries to dlopen its math dll, and fails, because the
libpython symbols are not exported.  A hack that fixes this is to do
"dlopen( "/usr/local/kde/lib/kde3/libkigpart.so", RTLD_GLOBAL )"
before loading the kig part library, thus causing the part to be first
loaded correctly, and making the ktrader lt_dlopen call discover that
the lib is already opened and not try to do it again, then all works
correctly.  Thus, I'm quite convinced that the problem is indeed in
the kdelibs/libltdl call not passing RTLD_GLOBAL as a dlopen flag,
contrary to what the docs say.

I have checked my local libltdl copy, which is more recent than the
kdelibs one, and the problem is fixed there, it seems.  So what
basically should happen is to just update the libltdl in kdelibs.  Me
personally, I'm still stuck with either explaining to my users why the
python math library won't load, or finding a hack^W more or less
portable workaround that makes it work on their system.  Suggestions
here are of course very much appreciated too :) But that's just my
problem, I suppose :)


I've run into a bug in kdelibs/libltd, which is fixed in more recent
versions of libltdl. It would be nice if this could be fixed by
upgrading kdelibs/libltdl to something more recent, at least for KDE
3.2, but preferably also in the branch..

thanks, and sorry for the long mail.. :)

[1]  From the libtool docs:
   " - Function: lt_dlhandle lt_dlopen (const char *FILENAME)
     Open the module with the file name FILENAME and return a handle
     for it.  `lt_dlopen' is able to open libtool dynamic modules,
     preloaded static modules, the program itself and native dynamic

     Unresolved symbols in the module are resolved using its dependency
     libraries (not implemented yet) and previously dlopened modules.
     If the executable using this module was linked with the
     `-export-dynamic' flag, then the global symbols in the executable
     will also be used to resolve references in the module."

More information about the kde-core-devel mailing list