Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: de432fd5d796e9d9ffa75fd8c8f53b44d80eae77
Ticket: 1961211fffffffffffffffffffffffffffffffff
TclpDlopen failing on MacOSX 10.4 and later
User & Date: sebbarre on 2008-05-09 20:24:53
Changes

  1. assignee changed to: "kennykb"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hi
    
    A change was made to tclLoadDyld.c to use the dlfcn API (dlopen) on MacOSX 10.4 or later instead of the obsolete/deprecated NSModule API.
    
    However, the call to dlopen is problematic:
      dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_LOCAL);
    
    RLTD_LOCAL is *not* the default value for dlopen, the default is RTLD_GLOBAL. RLTD_LOCAL prevents Tcl/Tk from being able to load any dynamic library/module which depends (i.e. was linked against) a previously loaded dynamic library/module.
    
    Unless I missed the rational for picking RLTD_LOCAL, could Tcl/Tk please use the default RLTD_GLOBAL?
    
    From the man page:
    http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/dlopen.3.html
    
    RTLD_GLOBAL: Symbols exported from this image (dynamic library or bundle) will be available to any images build with -flat_namespace option to ld(1) or to calls to dlsym() when using a spe-cial specialcial handle.
    
    RTLD_LOCAL: Symbols exported from this image (dynamic library or bundle) are generally hidden and only availble to dlsym() when directly using the handle returned by this call to dlopen().
    
    In the second case, a library/module A will load correctly but will hide its symbols. Tcl/Tk will fail to load a library/module B if B depends on symbols in A (i.e. was dynamically linked against A).
    
    Example:
    
    barre [562] $ /opt/tcltk8.5.0/bin/wish8.5 
    % load libvtkCommonTCL.dylib
    % load libvtkFilteringTCL.dylib
    dlopen(libvtkFilteringTCL.dylib, 6): Symbol not found: __Z14vtkTclInDeleteP10Tcl_Interp
      Referenced from: /Users/barre/build/VTK-VTK-5-2-tcl85-debug/bin/libvtkFilteringTCL.dylib
      Expected in: flat namespace
    
    the __Z14vtkTclInDeleteP10Tcl_Interp symbol *is* actually in libvtkCommonTCL.dylib.
    
    barre [563] $ otool -L libvtkFilteringTCL.dylib 
    libvtkFilteringTCL.dylib:
            libvtkFilteringTCL.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
            libvtkFiltering.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
            libvtkCommonTCL.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
            libvtkCommon.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
            /opt/tcltk8.5.0/lib/libtcl8.5.dylib (compatibility version 8.5.0, current version 8.5.0)
    [...]
    
    Manually changing RLTD_LOCAL to RLTD_GLOBAL, I was able to load both libraries without any problem inside Tcl/Tk 8.5.2.
    
    Thank you
    
  4. foundin changed to: "obsolete: 8.5.2"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "sebbarre"
  10. subsystem changed to: "40. Dynamic Loading"
  11. title changed to: "TclpDlopen failing on MacOSX 10.4 and later"
  12. type changed to: "Bug"