Tcl Source Code

View Ticket
Login
Ticket UUID: 611108
Title: LD_LIBRARY_PATH no longer used
Type: Bug Version: obsolete: 8.4.0
Submitter: jkbonfield Created on: 2002-09-18 14:11:38
Subsystem: 40. Dynamic Loading Assigned To: kennykb
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2002-10-10 19:26:41
Resolution: Fixed Closed By: vincentdarley
    Closed on: 2002-10-10 12:26:41
Description:
With 8.4.0 (compared to 8.3.1) "load libfred.so" no longer 
works unless libfred.so is in the current directory. Previously 
this searched the LD_LIBRARY_PATH on Unix, or PATH 
on Windows. (The searching is really done by dlopen().)

Since the inclusion of Tcl_FS* in 8.4 load now always calls 
dlopen() with a full pathname, thus preventing the system 
from searching LD_LIBRARY_PATH.

The cause is in TclpDlopen:

    native = Tcl_FSGetNativePath(pathPtr); 
    handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL); 

Tcl_GetString(pathPtr) returns "libfred.so", but native is now 
/some/dir/libfred.so. So removing the Tcl_FSGetNativePath 
cures this bug (at the extent of breaking much more).

I do not know what the proper solution is, but perhaps one 
way would be to extend load with a -native switch to 
accept the argument given to it as a native name already 
(and so it will not need to call Tcl_FSGetNativePath).
User Comments: vincentdarley added on 2002-10-10 19:26:41:
Logged In: YES 
user_id=32170

Committed fix.

jkbonfield added on 2002-10-07 20:36:32:
Logged In: YES 
user_id=154581

Further testing performed on Linux (RedHat 7.1), Digital Unix 
4.0E, Solaris 2.8 and Windows 2000. This now appears to work 
correctly on all platforms.

Thanks

jkbonfield added on 2002-10-04 00:19:09:
Logged In: YES 
user_id=154581

A preliminary test on linux and digital unix shows this as working. 
Next week I'll be able to do a more rigorous test on these 
platforms plus solaris and windows 2000.

Thanks.

vincentdarley added on 2002-10-03 22:18:10:

File Deleted - 32306: 



File Added - 32316: tclload.diff

vincentdarley added on 2002-10-03 22:18:09:
Logged In: YES 
user_id=32170

Sorry about that -- bad copy/pasting from the Windows 
version.  I've attached a modified patch.

Else you need to replace 'Tcl_UtfToExternal(' 
by 'Tcl_UtfToExternalDString(NULL,'

jkbonfield added on 2002-10-03 20:32:45:
Logged In: YES 
user_id=154581

It doesn't get too far. It complains about tcl_UtfToExternal 
being called with the wrong number of arguments.

This was on an Intel based linux:

gcc -pipe -c -O -D__NO_STRING_INLINES 
-D__NO_MATH_INLINES -Wall -Wconversion 
-Wno-implicit-int -fPIC -I./../generic -I. 
-DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 
-D_LARGEFILE64_SOURCE=1 
-DTCL_WIDE_INT_TYPE=long\ long 
-DHAVE_STRUCT_STAT64=1 -DHAVE_TYPE_OFF64_T=1 
-DHAVE_GETCWD=1 -DHAVE_OPENDIR=1 
-DHAVE_STRSTR=1 -DHAVE_STRTOL=1 
-DHAVE_STRTOLL=1 -DHAVE_STRTOULL=1 
-DHAVE_TMPNAM=1 -DHAVE_WAITPID=1 
-DHAVE_UNISTD_H=1 -DHAVE_SYS_PARAM_H=1 
-DUSE_TERMIOS=1 -DHAVE_SYS_TIME_H=1 
-DTIME_WITH_SYS_TIME=1 -DHAVE_TM_ZONE=1 
-DHAVE_GMTIME_R=1 -DHAVE_LOCALTIME_R=1 
-DHAVE_TM_GMTOFF=1 -DHAVE_TIMEZONE_VAR=1 
-DHAVE_ST_BLKSIZE=1 -DSTDC_HEADERS=1 
-DHAVE_SIGNED_CHAR=1 -DHAVE_LANGINFO=1 
-DHAVE_SYS_IOCTL_H=1         -DTCL_SHLIB_EXT=\".so\" 
./../unix/tclLoadDl.c
./../unix/tclLoadDl.c: In function `TclpDlopen':
./../unix/tclLoadDl.c:88: warning: passing arg 1 of 
`Tcl_UtfToExternal' from incompatible pointer type
./../unix/tclLoadDl.c:88: warning: passing arg 2 of 
`Tcl_UtfToExternal' makes pointer from integer without a cast
./../unix/tclLoadDl.c:88: warning: passing arg 3 of 
`Tcl_UtfToExternal' from incompatible pointer type
./../unix/tclLoadDl.c:88: too few arguments to function 
`Tcl_UtfToExternal'
./../unix/tclLoadDl.c:88: warning: assignment makes pointer 
from integer without a cast
gmake: *** [tclLoadDl.o] Error 1

vincentdarley added on 2002-10-03 20:13:10:

File Added - 32306: tclload.diff

Logged In: YES 
user_id=32170

Here's a patch which fixes this problem.  There is 
actually an important subtlety here which means we 
need to test both with Tcl_FSGetNativePath and with 
Tcl_GetString.

Please test asap, and we'll commit if all goes well.

vincentdarley added on 2002-09-19 15:59:36:
Logged In: YES 
user_id=32170

Take a look at tclWinLoad.c which shows you how you 
can do this:

    char *fileName = Tcl_GetString(pathPtr);
    nativeName = Tcl_WinUtfToTChar(fileName, -1, &ds);
    handle = (*tclWinProcs->loadLibraryProc)
(nativeName);

just use 'Tcl_GetString' and a manual 'Tcl_UtfToExternal' 
conversion inside TclpDlopen for .  Alternatively, if you 
simply use pkgIndex.tcl files to load your extensions, 
you won't run into this problem at all.

Attachments: