Tcl Source Code

View Ticket
Login
Ticket UUID: 3397938
Title: load fails due to RTLD_LOCAL
Type: Bug Created on: 2011-08-25 10:24:08
Submitter: uring Assigned to: nijtmans
Subsystem: 40. Dynamic Loading Severity:
Priority: 5 Medium Last modified: 2013-01-02 22:21:04
Status: Closed Closed by: nijtmans
Resolution: Fixed Closed on: 2013-01-02 15:21:04
Version: obsolete: 8.6b3
Description:
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?
User Comments:
nijtmans added on 2011-08-25 17:54:42:
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

ferrieux added on 2011-08-25 22:26:46:
What's the place to look for documentation of such ABI breakage ?

dgp added on 2011-08-26 22:41:12:
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?

dgp added on 2011-08-26 22:49:10:
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.

nijtmans added on 2011-09-21 19:47:11:
> 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).

nijtmans added on 2012-11-08 19:19:27:
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.

nijtmans added on 2013-01-02 22:21:04:

allow_comments - 1

Fixed in Tcl 8.6