#4913 load fails due to RTLD_LOCAL

obsolete: 8.6b3
closed-fixed
Jan Nijtmans
5
2013-01-02
2011-08-25
Ulrich Ring
No

after switching from tcl8.6b1 to tcl8.6b2 many of our apps are failing at startup when loading
extensions, for example:

> tclsh8.6
% load ./libfoo.so
% load ./libbar.so
...error: symbol lookup error: undefined symbol: .....

this happens, because (a) libbar references a symbol which is defined in libfoo and (b) because dlopen() in tclLoadDl.c passes the
flag RTLD_LOCAL (instead of RTLD_GLOBAL).

this seems to be a known problem, discussed for example in bug #3216070.

I understand the reasons why you came up with this change. But from a rather naive point of view
it causes a severe incompatibility, stopping the many apps here which are built upon the above
mentioned dependencies.

At present I see the following options:

(a) hacking tclLoadDl.c back to using RTDL_GLOBAL;
not an approach I were happy with. Instead I'd prefer
a compile option like -DLOAD_GLOBAL.
(b) getting an option "-global" in tcl8.6b3, though this
needs changing all "load .. " commands.
(c) changing the link of libbar.so introducing an
implicit depenency "-lfoo". don't know how
portable this advice ist. here (linux, SuSE 11.4,
binutils-2.21-13.1.x86_64) it seems to work.

What do you suggest to get around this load-failures?

Discussion

  • Jan Nijtmans
    Jan Nijtmans
    2011-08-25

    • assigned_to: dkf --> nijtmans
    • status: open --> closed-invalid
     
  • Jan Nijtmans
    Jan Nijtmans
    2011-08-25

    Well, the Issue tracker is not meant to ask questions, but
    anyway here is the anwer:

    (c) is the 'right' solution, and it works on all systems
    using ELF. If you want to make it portable, use TEA
    to build your libbar.so, then SHLIB_LD_LIBS is
    set to ${LIBS} for most systems and empty
    for systems that don't support it.

    Hope this helps,
    Jan Nijtmans

     
  • What's the place to look for documentation of such ABI breakage ?

     
  • Don Porter
    Don Porter
    2011-08-26

    Re-opened. At the least, this points out that
    I failed to flag this incompatibility in the release notes,
    and will want to do better on that for 8.6.0. As I
    mentioned on TCLCORE regarding plans for 8.6b3
    and beyond, I want to see documents take shape
    to help the Tcl user migrating to 8.6 on how they
    can take advantage of the changes in it. Do we
    have such guidance for this issue? If so, where
    is it?

     
  • Don Porter
    Don Porter
    2011-08-26

    • status: closed-invalid --> open
     
  • Don Porter
    Don Porter
    2011-08-26

    For background on the issues here see
    Tickets 1961211 and 3216070. Are there
    others?

    I'm not well-suited to weigh in on the matter,
    but from watching the back and forth on it,
    it looks like a situation where there is no one
    correct answer to suit everyone. Any choice
    will leave someone with the need to make
    adjustments. But don't take my word. Review
    the history.

     
  • Jan Nijtmans
    Jan Nijtmans
    2011-09-21

    > I want to see documents take shape
    > to help the Tcl user migrating to 8.6 on how
    > ...
    Remark: The change regarding RTLD_GLOBAL
    was done in Tcl 8.5 as well, so it has nothing to
    do with the migration to 8.6. In my option, it's
    a build problem, specifying an extra "-l" option
    should fix it, as option (c) mentioned above.
    On some platforms (e.g. Windows, AIX) this
    "-l" option should be there, otherwise the
    extension does not even compile. most
    ELF systems are more tolerant.

    If you want to be totally platform independant,
    use stubs, but on most modern systems just
    indicating on the command line which other
    libraries this library depends on should work
    just as well.

    Yes, there should be better documents on
    this (so keeping this issue open).

     
    • summary: load failes due to RTLD_LOCAL --> load fails due to RTLD_LOCAL
     
  • Jan Nijtmans
    Jan Nijtmans
    2012-11-08

    See: <http://www.tcl.tk/cgi-bin/tct/tip/416>

    Even though (c) is the recommended - portable -
    solution (using RTDL_GLOBAL is not portable
    anyway), I think the TIP explains pretty well
    when the -global flag could be used and what
    the danger is.

     
  • Jan Nijtmans
    Jan Nijtmans
    2012-11-08

    • milestone: 897381 --> obsolete: 8.6b3
     
    • labels: 105658 --> 40. Dynamic Loading
     
  • Jan Nijtmans
    Jan Nijtmans
    2013-01-02

    • status: open --> closed-fixed
     
  • Jan Nijtmans
    Jan Nijtmans
    2013-01-02

    Fixed in Tcl 8.6