Skip to content
Tcl Source Code History Of Ticket 2710920
Login

History Of Ticket 2710920

Artifacts Associated With Ticket 2710920

  1. Ticket change [45a9f4c8d9] (rid 99387) by jepler on 2009-03-25 03:05:51:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. 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 {}
      
    4. foundin initialized to: "obsolete: 8.5.6"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "jepler"
    10. subsystem initialized to: "37. File System"
    11. title initialized to: "[file tail] gives wrong result"
    12. type initialized to: "Bug"
  2. Ticket change [5a47b6fda3] (rid 118117) by jepler on 2009-03-25 10:05:52:

    1. icomment:
      
      
      File Added - 319464: filetailbug.tcl
      
      
      
    2. login: "jepler"
    3. mimetype: "text/plain"
    4. username: "jepler"
  3. Ticket change [4099e54847] (rid 116052) by jepler on 2009-03-25 10:07:16:

    1. 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) 
      
      
      
    2. login: "jepler"
    3. mimetype: "text/plain"
    4. username: "jepler"
  4. Ticket change [0f29d4b80a] (rid 94744) by dgp on 2009-03-25 11:59:04:

    1. assignee changed to: "dgp"
    2. priority changed to: "9 Immediate"
  5. Ticket change [3bd17eb637] (rid 112811) by jepler on 2009-03-26 07:05:49:

    1. icomment:
      
      
      File Deleted - 319464: 
      
      
      
    2. login: "jepler"
    3. mimetype: "text/plain"
    4. username: "jepler"
  6. Add attachment "fff.tcl" [0b9c9862ea] (rid 114027) by jepler on 2009-03-26 07:06:19.

  7. Ticket change [6b5685b4fc] (rid 128315) by jepler on 2009-03-26 07:06:19:

    1. icomment:
      
      
      File Added - 319626: fff.tcl
      
      
      
    2. login: "jepler"
    3. mimetype: "text/plain"
    4. username: "jepler"
  8. Ticket change [3db5699e02] (rid 121133) by jepler on 2009-03-26 07:08:33:

    1. 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/ {}
      $ 
      
      
      
    2. login: "jepler"
    3. mimetype: "text/plain"
    4. username: "jepler"
  9. Ticket change [8ad567ab63] (rid 127455) by dgp on 2009-03-27 00:47:41:

    1. 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
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [44f935a1eb] (rid 116799) by jepler on 2009-03-27 00:53:36:

    1. 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.
      
      
    2. login: "jepler"
    3. mimetype: "text/plain"
    4. username: "jepler"
  11. Ticket change [32cf9a2bbf] (rid 93686) by dgp on 2009-03-27 00:58:50:

    1. icomment:
      
      Further testing indicates that
      Tcl 8.5.0 works, while 8.5.1 has
      the bug.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  12. Ticket change [ee36442497] (rid 104042) by dgp on 2009-03-27 01:19:48:

    1. icomment:
      
      Sorry, I was misled by --enable-shared builds.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  13. Ticket change [ef0fcb831e] (rid 108926) by dgp on 2009-03-27 02:18:07:

    1. icomment:
      
      Bug introduced between 8.5.2 and 8.5.3.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  14. Ticket change [b4f05b2653] (rid 125139) by dgp on 2009-03-27 03:12:28:

    1. icomment:
      
      The fix for Bug 1972879 is to blame.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  15. Ticket change [2a52606235] (rid 118536) by dgp on 2009-03-27 04:20:26:

    1. 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.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  16. Ticket change [2cf6348f99] (rid 119004) by dgp on 2009-03-28 01:07:00:

    1. 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.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  17. Ticket change [e8ae894c67] (rid 104690) by dgp on 2009-03-28 01:47:57:

    1. icomment:
      
      [file dirname] suffers an analogous bug.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  18. Add attachment "2710920.patch" [0922701d9d] (rid 89663) by dgp on 2009-03-28 02:04:53.

  19. Ticket change [697ee271e7] (rid 103267) by dgp on 2009-03-28 02:04:53:

    1. icomment:
      
      
      File Added - 319929: 2710920.patch
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  20. Ticket change [8dd326f08e] (rid 128004) by dgp on 2009-03-28 02:20:43:

    1. closedate changed to: "2009-03-27T19:20:43"
    2. closer changed to: "dgp"
    3. icomment:
      
      
      allow_comments - 1
      
      
      Fixed for 8.5.7 and 8.6b2
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. subsystem changed to: "36. Pathname Management"
    9. username: "dgp"
  21. Ticket change [2ecbb125a3] (rid 92951) by ferrieux on 2009-03-28 04:30:10:

    1. icomment:
      Perhaps some chosen pieces of the very detailed and interesting description below could find a place in Filesystem.3 ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  22. Ticket change [225c558909] (rid 130735) by dgp on 2009-03-28 04:45:39:

    1. 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.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  23. Ticket change [a469461e2f] (rid 110202) by ferrieux on 2009-03-28 05:02:23:

    1. icomment:
      It hardly gets colder than that, eh ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"