Tcl Source Code

View Ticket
Login
Ticket UUID: 451571
Title: glob -directory -join bug in VFS
Type: Bug Version: obsolete: 8.4a3
Submitter: cenderis Created on: 2001-08-16 14:52:29
Subsystem: 37. File System Assigned To: vincentdarley
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-08-24 01:24:18
Resolution: Fixed Closed By: vincentdarley
    Closed on: 2001-08-23 18:24:18
Description:
I use stow a lot.  With stow, you install things in
subdirectories of (say) /usr/local/stow, and then stow
creates symbolic links as necessary in /usr/local/bin,
/usr/local/lib, etc.

That always used to work even with Tcl packages, but
now doesn't.  If I have a symbolic link in
/usr/local/lib, pointing at a directory containing a
pkgIndex.tcl, then tcl will no longer find it.

Specifically, if /usr/local/lib/tclodbc2.2 is a
symbolic link pointing at a directory containing the
stuff that TclODBC normally installs in
/usr/local/lib/tclodbc2.2, then "package require
tclodbc" throws the error "can't find package tclodbc".

Presumably this is part of the file system overhaul. 
I'm not sure whether it's a bug or a feature, but I
find it annoying.
User Comments: vincentdarley added on 2001-08-24 01:24:18:
Logged In: YES 
user_id=32170

Fixed in cvs head

dgp added on 2001-08-23 05:23:36:
Logged In: YES 
user_id=80530


Note that Tcl Patch 450340 includes the fix
for this bug.

dgp added on 2001-08-23 00:56:49:

File Added - 9852: jumbo.patch

Logged In: YES 
user_id=80530


Confirmed that these patches fix the reported
bug.  Here they are as an all-in-one jumbo patch.

Want to commit it, Vince, or will
it conflict with your work on 450340 ?

dgp added on 2001-08-22 23:34:28:

File Deleted - 9742: 

Logged In: YES 
user_id=80530

Delete duplicates and obsolete patches

vincentdarley added on 2001-08-22 17:58:23:

File Added - 9835: tclUnixFile.diff.c

vincentdarley added on 2001-08-22 17:58:22:
Logged In: YES 
user_id=32170

Ok, here's a patch (the problem is I'm making changes 
elsewhere in that file).  I think this should work (at 
least it works for me on some unix OS).  Also attached a 
patch to the test file.

vincentdarley added on 2001-08-22 17:58:00:

File Added - 9834: tclUnixFile.diff.c

Logged In: YES 
user_id=32170

Ok, here's a patch (the problem is I'm making changes 
elsewhere in that file).  I think this should work (at 
least it works for me on some unix OS).  Also attached a 
patch to the test file.

vincentdarley added on 2001-08-22 17:56:48:

File Added - 9833: tclUnixFile.diff.c

Logged In: YES 
user_id=32170

Ok, here's a patch (the problem is I'm making changes 
elsewhere in that file).  I think this should work (at 
least it works for me on some unix OS).  Also attached a 
patch to the test file.

vincentdarley added on 2001-08-22 17:56:28:

File Added - 9832: fileName.diff.test

Logged In: YES 
user_id=32170

Attaching test suite patch (note: one of these tests should 
fail on Tcl8.3.3, three will fail in Tcl 8.4a3, and none 
should fail after the other patch has been applied).

vincentdarley added on 2001-08-22 17:55:01:

File Added - 9831: tclUnixFile.diff.c

Logged In: YES 
user_id=32170

Ok, here's a patch (the problem is I'm making changes 
elsewhere in that file).  I think this should work (at 
least it works for me on some unix OS).  Also attached a 
patch to the test file.

dgp added on 2001-08-21 01:44:18:

File Added - 9748: glob.patch

Logged In: YES 
user_id=80530

Vince, are you able to attach files here?  If so,
please do so.  It avoids the mangling of code
formatting in the comments.  Plus patches are
easier to apply.

If not, let's find out why not and correct the
situation.

I tried integrating the code you offered.  I'm
attaching the patch I produced.  Unfortunately,
the patch breaks package loading completely:

% glob -directory [info library] -join * pkgIndex.tcl
no files matched glob pattern "*/pkgIndex.tcl"

I probably integrated it wrong.  Please advise.

nobody added on 2001-08-21 01:07:56:
Logged In: NO 

I've found the problem -- the bug actually existed in 8.3 
but was only exercised due to FS overhaul.  I'll commit the 
fixes (to Win/Mac too) when I commit some other FS 
changes.  In the meantime, if you want a fix, replace the 
appropriate block of code in tclUnixFile.c with this:

    if (types != NULL) {
struct stat buf;

if (types->perm != 0) {
    if (TclpStat(fname, &buf) != 0) {
/* 
 * Either the file has disappeared 
between the
 * 'readdir' call and 
the 'TclpStat' call, or
 * the file is a link to a file 
which doesn't
 * exist (which we could ascertain 
with
 * TclpLstat), or there is some 
other strange
 * problem.  In all these cases, we 
define this
 * to mean the file does not match 
any defined
 * permission, and therefore it is 
not 
 * added to the list of files to 
return.
 */
typeOk = 0;
    }
    
    /* 
     * readonly means that there are NO 
write permissions
     * (even for user), but execute is OK 
for anybody
     */
    if (typeOk && (
((types->perm & 
TCL_GLOB_PERM_RONLY) &&
(buf.st_mode & 
(S_IWOTH|S_IWGRP|S_IWUSR))) ||
((types->perm & TCL_GLOB_PERM_R) &&
(TclpAccess(fname, R_OK) != 
0)) ||
((types->perm & TCL_GLOB_PERM_W) &&
(TclpAccess(fname, W_OK) != 
0)) ||
((types->perm & TCL_GLOB_PERM_X) &&
(TclpAccess(fname, X_OK) != 
0))
)) {
typeOk = 0;
    }
}
if (typeOk && (types->type != 0)) {
    if (types->perm == 0) {
/* We haven't yet done a stat on 
the file */
if (TclpStat(fname, &buf) != 0) {
    /* Posix error occurred */
    typeOk = 0;
}
    }
    if (typeOk) {
/*
 * In order bcdpfls as in 'find -t'
 */
if (
    ((types->type & 
TCL_GLOB_TYPE_BLOCK) &&
    S_ISBLK(buf.st_mode)) ||
    ((types->type & 
TCL_GLOB_TYPE_CHAR) &&
    S_ISCHR(buf.st_mode)) ||
    ((types->type & 
TCL_GLOB_TYPE_DIR) &&
    S_ISDIR(buf.st_mode)) ||
    ((types->type & 
TCL_GLOB_TYPE_PIPE) &&
    S_ISFIFO(buf.st_mode)) 
||
    ((types->type & 
TCL_GLOB_TYPE_FILE) &&
    S_ISREG(buf.st_mode))
#ifdef S_ISSOCK
    || ((types->type & 
TCL_GLOB_TYPE_SOCK) &&
    S_ISSOCK(buf.st_mode))
#endif
    ) {
    /* Do nothing -- this file is 
ok */
} else {
    typeOk = 0;
#ifdef S_ISLNK
    if (types->type & 
TCL_GLOB_TYPE_LINK) {
if (TclpLstat(fname, &buf) 
== 0) {
    if (S_ISLNK
(buf.st_mode)) {
        typeOk = 1;
    }
}
    }
#endif
}
    }
}
    }

dgp added on 2001-08-20 23:34:28:

File Added - 9742: globtest.patch

Logged In: YES 
user_id=80530

The attached patch adds a test to
tests/filname.test that demos the bug.
The test passes in Tcl 8.3.3, but fails
in Tcl 8.4a3 due to mishandling of
symlinks by [glob -directory ... -join ]

Assigning to "FileSystem" for further work.

dgp added on 2001-08-20 22:51:22:
Logged In: YES 
user_id=80530

Ah.  I see.  How clever.  I'll have to adapt
that technique for my own testing installation.

I can now confirm the problem.  I've narrowed
it down to a bug in [glob], probably related
to the new VFS support.  Working on a demo
script now...

cenderis added on 2001-08-20 22:29:08:
Logged In: YES 
user_id=16560

info library returns /usr/local/lib/tcl8.4

Tcl is configured and built as normal.  When installing, I
use "make install prefix=/usr/local/stow/tcl
exec_prefix=/usr/local/stow/tcl".  Then I run stow which
creates symbolic links elsewhere in /usr/local/*.

dgp added on 2001-08-20 22:16:10:
Logged In: YES 
user_id=80530

In the original report, is Tcl/tclsh installed with
prefix and exec_prefix both set to /usr/local, or
are symlinks being used there as well to give the
appearance that Tcl/tclsh are installed there when they
are really elsewhere.

More simply:  What does [info library] return?

vincentdarley added on 2001-08-17 16:32:29:
Logged In: YES 
user_id=32170

As above, presumably this was part of the filesystem 
overhaul, and is I'm sure a bug.  If the bug reporter or 
package maintainer can reduce this down to one or more 
filesystem commands which together give the wrong result 
(i.e. where exactly in the complex 'package require' 
mechanism do things go wrong), we can reassign it to 
filesystem and I may be able to see how to fix it.

Attachments: