Artifacts Associated With Ticket 2710920fffffffff
Ticket change [45a9f4c8d9] (rid 99387) by jepler on 2009-03-25 03:05:51:
- assignee initialized to: "vincentdarley"
- cmimetype initialized to: "text/plain"
- comment initialized to:
This problem occurs on a freshly built 8.5.6 (unmodified) on Ubuntu Hardy and is also seen on 8.5.3-2 on ubuntu jaunty alpha (ubuntu modified). The bug is not seen in 8.4.16-4ubuntu1 (ubuntu modified) on ubuntu hardy. In a specific scenario involving [glob] with a trailing slash, the resulting files are treated improperly by [file tail]. An attached script, which can be run by $ make shell SCRIPT=filetailbug.tcl demonstrates the problem on my system. Expected output: /bin bin Actual output: /bin {} - foundin initialized to: "obsolete: 8.5.6"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "jepler"
- subsystem initialized to: "37. File System"
- title initialized to: "[file tail] gives wrong result"
- type initialized to: "Bug"
Ticket change [5a47b6fda3] (rid 118117) by jepler on 2009-03-25 10:05:52:
- icomment:
File Added - 319464: filetailbug.tcl
- login: "jepler"
- mimetype: "text/plain"
- username: "jepler"
- icomment:
Ticket change [4099e54847] (rid 116052) by jepler on 2009-03-25 10:07:16:
- icomment:
I am not familiar with the tcl path object, but I attempted to generate some useful debugging information. I found that the 'normPathPtr' is an empty string, and that TclPathpart returns normPathPtr, leading to the result I am seeing. Perhaps the problem is occurring earlier at the point where this path object is constructed? Breakpoint 3, TclPathPart (interp=0x606400, pathPtr=0x62aa00, portion=TCL_PATH_TAIL) at /tmp/tcl8.5.6/unix/../generic/tclPathObj.c:596 596const char *rest = TclGetString(fsPathPtr->normPathPtr); (gdb) print fsPathPtr->translatedPathPtr->bytes $32 = 0x636be0 "/bin" (gdb) print fsPathPtr->normPathPtr->bytes $33 = 0x7f2ed6902b48 "" (gdb) next 598if (strchr(rest, '/') != NULL) { (gdb) 601if (tclPlatform == TCL_PLATFORM_WINDOWS (gdb) 605Tcl_IncrRefCount(fsPathPtr->normPathPtr); (gdb) 606return fsPathPtr->normPathPtr; (gdb) 747} (gdb) - login: "jepler"
- mimetype: "text/plain"
- username: "jepler"
- icomment:
Ticket change [0f29d4b80a] (rid 94744) by dgp on 2009-03-25 11:59:04:
- assignee changed to: "dgp"
- priority changed to: "9 Immediate"
Ticket change [3bd17eb637] (rid 112811) by jepler on 2009-03-26 07:05:49:
- icomment:
File Deleted - 319464:
- login: "jepler"
- mimetype: "text/plain"
- username: "jepler"
- icomment:
Add attachment "fff.tcl" [0b9c9862ea] (rid 114027) by jepler on 2009-03-26 07:06:19.
Ticket change [6b5685b4fc] (rid 128315) by jepler on 2009-03-26 07:06:19:
- icomment:
File Added - 319626: fff.tcl
- login: "jepler"
- mimetype: "text/plain"
- username: "jepler"
- icomment:
Ticket change [3db5699e02] (rid 121133) by jepler on 2009-03-26 07:08:33:
- icomment:
I failed to correctly minimize the test case in my original submission. Please see the attached 'fff.tcl' instead of the original attachment. $ cat fff.tcl proc f {} { set d [glob -nocomplain /*/] set d [lindex $d 0] #set d [format %s $d] # uncommenting this line makes both 8.4 and 8.5 work puts stderr [list $d [file tail $d]] } f $ make shell SCRIPT=fff.tcl LD_LIBRARY_PATH="`pwd`:${LD_LIBRARY_PATH}"; export LD_LIBRARY_PATH; \ TCL_LIBRARY="/tmp/tcl8.5.6/library"; export TCL_LIBRARY; \ ./tclsh fff.tcl /mnt/ {} $ - login: "jepler"
- mimetype: "text/plain"
- username: "jepler"
- icomment:
Ticket change [8ad567ab63] (rid 127455) by dgp on 2009-03-27 00:47:41:
- icomment:
I can now reproduce the problem with Tcl 8.5.6: $ make shell SCRIPT=fff.tcl ... LD_LIBRARY_PATH="`pwd`:${LD_LIBRARY_PATH}"; export LD_LIBRARY_PATH; \ TCL_LIBRARY="/home/dgp/cvs/tcl8.5.6/library"; export TCL_LIBRARY; \ ./tclsh fff.tcl /opt/ {} Note that a very similar attempt yields different results: $ make shell SCRIPT=~/fff.tcl ... LD_LIBRARY_PATH="`pwd`:${LD_LIBRARY_PATH}"; export LD_LIBRARY_PATH; \ TCL_LIBRARY="/home/dgp/cvs/tcl8.5.6/library"; export TCL_LIBRARY; \ ./tclsh ~/fff.tcl /opt/ opt Same script in a different place and accessed via an absolute path. So inspired by that difference, try: $ make shell SCRIPT=`pwd`/fff.tcl ... LD_LIBRARY_PATH="`pwd`:${LD_LIBRARY_PATH}"; export LD_LIBRARY_PATH; \ TCL_LIBRARY="/home/dgp/cvs/tcl8.5.6/library"; export TCL_LIBRARY; \ ./tclsh /home/dgp/cvs/tcl8.5.6/unix/fff.tcl /opt/ opt - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [44f935a1eb] (rid 116799) by jepler on 2009-03-27 00:53:36:
- icomment:
I'm glad you found how to reproduce it! I can confirm what dgp says: whether the script is given as an absolute path or not affects the output.
- login: "jepler"
- mimetype: "text/plain"
- username: "jepler"
- icomment:
Ticket change [32cf9a2bbf] (rid 93686) by dgp on 2009-03-27 00:58:50:
- icomment:
Further testing indicates that Tcl 8.5.0 works, while 8.5.1 has the bug.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [ee36442497] (rid 104042) by dgp on 2009-03-27 01:19:48:
- icomment:
Sorry, I was misled by --enable-shared builds.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [ef0fcb831e] (rid 108926) by dgp on 2009-03-27 02:18:07:
- icomment:
Bug introduced between 8.5.2 and 8.5.3.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b4f05b2653] (rid 125139) by dgp on 2009-03-27 03:12:28:
- icomment:
The fix for Bug 1972879 is to blame.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [2a52606235] (rid 118536) by dgp on 2009-03-27 04:20:26:
- icomment:
Appears that the fix of 1972879 did not create this bug, but just exposed it, by permitting some otherwise untested codepaths to execute. Problem is that [file tail] on the PATHFLAGS !=0 intrep for path values is just broken when paths have trailing separators.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [2cf6348f99] (rid 119004) by dgp on 2009-03-28 01:07:00:
- icomment:
The mystery as to why the behavior is different whether or not the demo script is [source]d by relative or absolute name is complex, but explainable. When the file name is absolute, there's never any need to ask what the [pwd] value is in order to open and read that file. In this simple test script, it happens that nothing else needed to know that value either, so the value of [pwd] has never been determined. In the innermost part of the [glob] operation, we need to query the actual filesystem to determine what files exist. The routine TclpMatchInDirectory() in tclUnixFile.c does this, and it must construct the "native" name of the file to do so. It calls the routine Tcl_FSGetNativePath() to get that native name. This works its way back to the routine TclNativeCreateNativeRep() also in tclUnixFile.c. TNCNR has two branches depending on whether or not the [pwd] value is known to be in the native filesystem. In the case where we've never had reason to determine [pwd] up to that point, [pwd] is not known to be in the native filesystem, so a less efficient, safer path to generating the native name is taken by normalizing the path first. Normalizing the path converts it out of the intrep which triggers the bug. On the other hand, when the pathname of the demo script is relative, we had to compute [pwd] just to find and source the script, so we have the value and we know it's in the native filesystem, so within TNCNR we take a more efficient path to computing the native name which also preserves the intrep which is needed to demo the [file tail] bug. Perhaps more than you wanted to know, but I figured it should be written down somewhere.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [e8ae894c67] (rid 104690) by dgp on 2009-03-28 01:47:57:
- icomment:
[file dirname] suffers an analogous bug.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Add attachment "2710920.patch" [0922701d9d] (rid 89663) by dgp on 2009-03-28 02:04:53.
Ticket change [697ee271e7] (rid 103267) by dgp on 2009-03-28 02:04:53:
- icomment:
File Added - 319929: 2710920.patch
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [8dd326f08e] (rid 128004) by dgp on 2009-03-28 02:20:43:
- closedate changed to: "2009-03-27T19:20:43"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 Fixed for 8.5.7 and 8.6b2
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- subsystem changed to: "36. Pathname Management"
- username: "dgp"
Ticket change [2ecbb125a3] (rid 92951) by ferrieux on 2009-03-28 04:30:10:
- icomment:
Perhaps some chosen pieces of the very detailed and interesting description below could find a place in Filesystem.3 ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [225c558909] (rid 130735) by dgp on 2009-03-28 04:45:39:
- icomment:
No; I like to limit the docs to things I like and want to keep. Internal details of dubious wisdom deserve writeups sometimes, but not in the docs.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [a469461e2f] (rid 110202) by ferrieux on 2009-03-28 05:02:23:
- icomment:
It hardly gets colder than that, eh ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment: