Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-08-22
02:11 • Ticket [2837800fff] glob errors searching dirs matching ~* status still Cl... artifact: 67198e1de2 user: dgp
2009-08-21
05:10 • Closed ticket [2837800fff]. artifact: f89c2520d4 user: dgp
04:56 • Ticket [2837800fff]: 4 changes artifact: 2cde3228de user: dgp
04:56 • Add attachment 2837800.patch to ticket [2837800fff] artifact: a18c4c9a8f user: dgp
04:56 • Ticket [2837800fff] glob errors searching dirs matching ~* status still Op... artifact: b800c4c18c user: dgp
2009-08-20
21:42 • Ticket [2837800fff]: 1 change artifact: 902b0f058d user: dgp
2009-08-18
21:34 • Ticket [2837800fff]: 4 changes artifact: 5e2fa22ff9 user: dgp
20:10 • Ticket [2837800fff]: 4 changes artifact: 6d8f90cfaa user: dgp
20:10 • Ticket [2837800fff]: 4 changes artifact: c9e24d00c0 user: dgp
04:21 • Ticket [2837800fff]: 4 changes artifact: 1447296c88 user: dgp
03:00 • Ticket [2837800fff]: 4 changes artifact: a15c2947ae user: dgp
2009-08-15
03:07 • Ticket [2837800fff]: 4 changes artifact: 9e40fd8e96 user: dgp
03:07 • Add attachment 2837800-84.patch to ticket [2837800fff] artifact: 0e318d2354 user: dgp
03:07 • Ticket [2837800fff] glob segfault searching dirs matching ~* status still ... artifact: e5e09c41b6 user: dgp
02:41 • Ticket [2837800fff]: 4 changes artifact: 583a0cb27b user: dgp
01:38 • Ticket [2837800fff]: 4 changes artifact: 77b14e375a user: dgp
01:34 • Ticket [2837800fff]: 4 changes artifact: 57c414d0f0 user: dgp
01:32 • Ticket [2837800fff]: 4 changes artifact: f414143aff user: dgp
00:59 • Ticket [2837800fff]: 5 changes artifact: 7ef24ff9fd user: dgp
2009-08-14
17:57 • New ticket [2837800fff]. artifact: ec71b5e494 user: dgp

[glob] errors searching dirs matching ~*

Closed / Fixed2837800fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-08-14 17:57:15
% file mkdir ./~goo
% close [open ./~goo/test w]
% glob [file join * test]
make: *** [shell] Segmentation fault
dgpplain2009-08-15 00:59:48
Stack trace from debug build of the
tip of the core-8-5-branch:

Program received signal SIGSEGV, Segmentation fault.
0x0807bf8a in Tcl_DbDecrRefCount (objPtr=0x0,
    file=0x8160368 "/home/dgp/cvs/tcl8.5/unix/../generic/tclPathObj.c",
    line=1690) at /home/dgp/cvs/tcl8.5/unix/../generic/tclObj.c:3153
3153        if (objPtr->refCount == 0x61616161) {
(gdb) bt
#0  0x0807bf8a in Tcl_DbDecrRefCount (objPtr=0x0,
    file=0x8160368 "/home/dgp/cvs/tcl8.5/unix/../generic/tclPathObj.c",
    line=1690) at /home/dgp/cvs/tcl8.5/unix/../generic/tclObj.c:3153
#1  0x080820c9 in Tcl_FSGetTranslatedPath (interp=0x89098d0, pathPtr=0x89752d8)
    at /home/dgp/cvs/tcl8.5/unix/../generic/tclPathObj.c:1690
#2  0x080ad652 in TclpMatchInDirectory (interp=0x89098d0, resultPtr=0x8974d10,
    pathPtr=0x89752d8, pattern=0x0, types=0x0)
    at /home/dgp/cvs/tcl8.5/unix/../unix/tclUnixFile.c:222
#3  0x080682ba in Tcl_FSMatchInDirectory (interp=0x89098d0,
    resultPtr=0x8974d10, pathPtr=0x89752d8, pattern=0x0, types=0x0)
    at /home/dgp/cvs/tcl8.5/unix/../generic/tclIOUtil.c:1102
#4  0x08145dc6 in DoGlob (interp=0x89098d0, matchesObj=0x8974d10,
    separators=0x816f602 "/", pathPtr=0x8975010, flags=1,
    pattern=0x897454a "test", types=0x0)
    at /home/dgp/cvs/tcl8.5/unix/../generic/tclFileName.c:2478
#5  0x08145941 in DoGlob (interp=0x89098d0, matchesObj=0x8974d10,
    separators=0x816f602 "/", pathPtr=0x0, flags=0,
    pattern=0x8974548 "*/test", types=0x0)
    at /home/dgp/cvs/tcl8.5/unix/../generic/tclFileName.c:2364
#6  0x08145010 in TclGlob (interp=0x89098d0, pattern=0x8974548 "*/test",
    pathPrefix=0x0, globFlags=0, types=0x0)
    at /home/dgp/cvs/tcl8.5/unix/../generic/tclFileName.c:1914
#7  0x0814471e in Tcl_GlobObjCmd (dummy=0x0, interp=0x89098d0, objc=1,
    objv=0x890ac6c) at /home/dgp/cvs/tcl8.5/unix/../generic/tclFileName.c:1584
...
dgpplain2009-08-15 01:32:31
In Tcl 8.4, there is no crash, but
the incorrect result is not much better:

% glob [file join * test]

%
dgpplain2009-08-15 01:34:56
8.3.5 works fine.
dgpplain2009-08-15 01:38:03
The actual releases of Tcl 8.4, up through
8.4.19 are slightly better:

% glob */test
no files matched glob pattern "*/test"

It's a wrong result, but at least without
the empty error message demonstrated
in the tip of the core-8-4-branch.
dgpplain2009-08-15 02:41:45
A different variation of the same bug
in Tcl 8.4:

% file mkdir ./~dgp ;# empty directory
% glob */.mozilla
~dgp/.mozilla

The search in subdirectories of
the current directory is actually
finding something way over 
in my home directory instead.
dgpplain2009-08-15 03:07:31
File Added - 339245: 2837800-84.patch
dgpplain2009-08-15 03:07:51
Attached patch fixes things in 8.4.
dgpplain2009-08-18 03:00:13
fix with tests committed for 8.4.20.
dgpplain2009-08-18 04:21:51
In 8.5+, I observe that the header comments
of TclNewFSPathObj() claim that the dirPtr
argument must be an absolute path, but
when DoGlob() calls this routine, it makes
no effort to check that constraint is met.

It's not clear whether the header comment
claim is true, or where it gets relied on, if
anywhere.
dgpplain2009-08-18 20:10:21
When the user "goo" does not exist, then
the value "~goo" cannot be converted to
the "path" Tcl_ObjType.

The PATH_FLAGS == 0 representation
for a "path" value holds two parts of the
path.  In the crashing case, the head
part of the path is "~goo" and the tail
part is "test".  It is assumed deep in the
code that the head part of the path can
always be converted to the "path"
Tcl_ObjType.  There is no check for
the NULL result when that is not true,
and that leads to the crash.
dgpplain2009-08-18 20:10:57
sorry, that's the PATH_FLAGS != 0 representation.
dgpplain2009-08-18 21:34:50
handling the NULL return solves the
crash, leaving only the bug.  Will
commit if/when SF CVS returns.
dgp Ticket [2837800fff]: 1 change [History diff]2009-08-20 21:42:11
dgpplain2009-08-21 04:56:26
File Added - 339991: 2837800.patch
dgpplain2009-08-21 04:56:39
Attached patch for 8.5
dgpplain2009-08-21 05:10:34
allow_comments - 1


Patch committed for 8.5.8 and 8.6b2.
dgpplain2009-08-22 02:11:48
subsequent commits corrected a regression.
Log in (anonymous is fine) to add a comment.

Attachments: