Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-10-10
19:26 • Closed ticket [611108ffff]: LD_LIBRARY_PATH no longer used plus 7 other chan... artifact: 7da024271d user: vincentdarley
2002-10-07
20:36 • Ticket [611108ffff]: 4 changes artifact: 3ea65a72ce user: jkbonfield
2002-10-04
00:19 • Ticket [611108ffff]: 4 changes artifact: ef3c511b32 user: jkbonfield
2002-10-03
22:18 • Ticket [611108ffff]: 4 changes artifact: a4f7fa75b8 user: vincentdarley
22:18 • Add attachment tclload.diff to ticket [611108ffff] artifact: 41857cfba4 user: vincentdarley
22:18 • Ticket [611108ffff] LD_LIBRARY_PATH no longer used status still Open with 4 ... artifact: 2aedfaa923 user: vincentdarley
20:32 • Ticket [611108ffff]: 4 changes artifact: 62a77e6862 user: jkbonfield
20:13 • Ticket [611108ffff]: 4 changes artifact: 0b77009e7f user: vincentdarley
2002-09-19
15:59 • Ticket [611108ffff]: 4 changes artifact: 70d8d3a9ac user: vincentdarley
2002-09-18
14:11 • New ticket [611108ffff]. artifact: 202e2a87d0 user: jkbonfield

LD_LIBRARY_PATH no longer used

Closed / Fixed611108ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-09-18 14:11:38
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).
vincentdarleyplain2002-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.
vincentdarleyplain2002-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.
jkbonfieldplain2002-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
vincentdarleyplain2002-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,'
vincentdarleyplain2002-10-03 22:18:10
File Deleted - 32306: 



File Added - 32316: tclload.diff
jkbonfieldplain2002-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.
jkbonfieldplain2002-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
vincentdarleyplain2002-10-10 19:26:41
Logged In: YES 
user_id=32170

Committed fix.
Log in (anonymous is fine) to add a comment.

Attachments: