Tcl Source Code

Check-in [58a4f59ea3]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[Bug #3216070] Loading extension libraries from embedded Tcl applications.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | potential incompatibility
Files: files | file ages | folders
SHA1: 58a4f59ea35e933bfe22766145598b88473a358e
User & Date: jan.nijtmans 2011-03-22 10:14:00
Context
2011-03-22
10:15
typo check-in: 6ef9ab3ad5 user: jan.nijtmans tags: trunk
10:14
[Bug #3216070] Loading extension libraries from embedded Tcl applications. check-in: 58a4f59ea3 user: jan.nijtmans tags: trunk, potential incompatibility
10:10
[Bug #3216070] Loading extension libraries from embedded Tcl applications. check-in: e18262f10e user: jan.nijtmans tags: core-8-5-branch, potential incompatibility
2011-03-21
14:42
remove one level of allocator indirection in non-memdebug builds, imported from mig-alloc-reform. check-in: d74d7bb013 user: mig tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ChangeLog.

            1  +2011-03-21  Jan Nijtmans  <[email protected]>
            2  +
            3  +	* unix/tclLoadDl.c:    [Bug #3216070] Loading extension libraries
            4  +	* unix/tclLoadDyld.c:  from embedded Tcl applications.
            5  +
     1      6   2011-03-21  Miguel Sofer  <[email protected]>
     2      7   
     3      8   	* generic/tclCkAlloc.c:
     4      9   	* generic/tclInt.h: remove one level of allocator indirection in
     5     10   	non memdebug builds, imported from mig-alloc-reform.
     6     11   
     7     12   2011-03-20  Miguel Sofer  <[email protected]>

Changes to unix/tclLoadDl.c.

    15     15   #   include "../compat/dlfcn.h"
    16     16   #else
    17     17   #   include <dlfcn.h>
    18     18   #endif
    19     19   
    20     20   /*
    21     21    * In some systems, like SunOS 4.1.3, the RTLD_NOW flag isn't defined and this
    22         - * argument to dlopen must always be 1. The RTLD_GLOBAL flag is needed on some
    23         - * systems (e.g. SCO and UnixWare) but doesn't exist on others; if it doesn't
    24         - * exist, set it to 0 so it has no effect.
           22  + * argument to dlopen must always be 1. The RTLD_LOCAL flag doesn't exist on
           23  + * some platforms; if it doesn't exist, set it to 0 so it has no effect.
           24  + * See [Bug #3216070]
    25     25    */
    26     26   
    27     27   #ifndef RTLD_NOW
    28     28   #   define RTLD_NOW 1
    29     29   #endif
    30     30   
    31         -#ifndef RTLD_GLOBAL
    32         -#   define RTLD_GLOBAL 0
           31  +#ifndef RTLD_LOCAL
           32  +#   define RTLD_LOCAL 0
    33     33   #endif
    34     34   
    35     35   /*
    36     36    * Static procedures defined within this file.
    37     37    */
    38     38   
    39     39   static void *		FindSymbol(Tcl_Interp *interp,
................................................................................
    78     78       /*
    79     79        * First try the full path the user gave us. This is particularly
    80     80        * important if the cwd is inside a vfs, and we are trying to load using a
    81     81        * relative path.
    82     82        */
    83     83   
    84     84       native = Tcl_FSGetNativePath(pathPtr);
    85         -    handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL);
           85  +    /*
           86  +     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
           87  +     */
           88  +    handle = dlopen(native, RTLD_NOW | RTLD_LOCAL);
    86     89       if (handle == NULL) {
    87     90   	/*
    88     91   	 * Let the OS loader examine the binary search path for whatever
    89     92   	 * string the user gave us which hopefully refers to a file on the
    90     93   	 * binary path.
    91     94   	 */
    92     95   
    93     96   	Tcl_DString ds;
    94     97   	const char *fileName = Tcl_GetString(pathPtr);
    95     98   
    96     99   	native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
    97         -	handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL);
          100  +	/*
          101  +	 * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
          102  +	 */
          103  +	handle = dlopen(native, RTLD_NOW | RTLD_LOCAL);
    98    104   	Tcl_DStringFree(&ds);
    99    105       }
   100    106   
   101    107       if (handle == NULL) {
   102    108   	/*
   103    109   	 * Write the string to a variable first to work around a compiler bug
   104    110   	 * in the Sun Forte 6 compiler. [Bug 1503729]

Changes to unix/tclLoadDyld.c.

   203    203       nativePath = Tcl_FSGetNativePath(pathPtr);
   204    204   
   205    205   #if TCL_DYLD_USE_DLFCN
   206    206   #if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
   207    207       if (tclMacOSXDarwinRelease >= 8)
   208    208   #endif
   209    209       {
   210         -	dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_GLOBAL);
          210  +    /*
          211  +     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
          212  +     */
          213  +	dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_LOCAL);
   211    214   	if (!dlHandle) {
   212    215   	    /*
   213    216   	     * Let the OS loader examine the binary search path for whatever
   214    217   	     * string the user gave us which hopefully refers to a file on the
   215    218   	     * binary path.
   216    219   	     */
   217    220   
   218    221   	    fileName = Tcl_GetString(pathPtr);
   219    222   	    nativeFileName = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
   220         -	    dlHandle = dlopen(nativeFileName, RTLD_NOW | RTLD_GLOBAL);
          223  +	    /*
          224  +	     * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
          225  +	     */
          226  +	    dlHandle = dlopen(nativeFileName, RTLD_NOW | RTLD_LOCAL);
   221    227   	}
   222    228   	if (dlHandle) {
   223    229   	    TclLoadDbgMsg("dlopen() successful");
   224    230   	} else {
   225    231   	    errMsg = dlerror();
   226    232   	    TclLoadDbgMsg("dlopen() failed: %s", errMsg);
   227    233   	}