Skip to content
Tcl Source Code History Of Ticket 218871
Login

History Of Ticket 218871

Artifacts Associated With Ticket 218871

  1. Ticket change [aa62eea50e] (rid 100917) by nobody on 2000-10-26 01:07:00:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 2480 Bug
      Version: 8.2b1
      SubmitDate: '1999-08-02'
      LastModified: '2000-01-28'
      Severity: MED
      Status: Released
      Submitter: techsupp
      ChangedBy: ericm
      RelatedBugIDs: 2611
      OS: All
      FixedDate: '2000-01-28'
      FixedInVersion: 8.3
      ClosedDate: '2000-10-25'
      
      
      Name:
      
      Krzysztof Kozminski
      
      
      CVS:
      
      RCS: @(#) $Id: auto.tcl,v 1.2 1999/04/16 00:46:56 stanton Exp $ and RCS: @(#) $Id: init.tcl,v 1.31 1999/06/25 23:29:53 welch Exp $
      
      
      Comments:
      
      The
      
          return [expr {[info commands $name] != ""}]
      
      
      line in proc auto_load should be also fixed to query the appropriate
      
      namespace for the origin of the command, but I did not have any old
      
      auto_mkindex versions to generate non-canonical auto_index entries to
      
      test this part.
      
      
      Also, where is test "autoMkindex-3.3" ?  I just might take you up on the
      
      gold star offer :-)
      
      
      ReproducibleScript:
      
      Prepare a file /tmp/test.tcl with the following contents:
      
      
      proc {ugly* $procname [error GOTCHA!]} {some args} {
      
          puts "$some $args"
      
      }
      
      proc {ugly*\*\\* \$\\$\\\$procname [\[\\[error GOTCHA!]]]} {some args} {
      
          puts "$some $args"
      
      }
      
      
      Invoke protclsh82 and convince yourself that the procedure names are
      
      quite legitimate and work just fine:
      
      
      protclsh82
      
      % source /tmp/test.tcl
      
      % {ugly* $procname [error GOTCHA!]} this will be echoed
      
      this will be echoed
      
      % {ugly*\*\\* \$\\$\\\$procname [\[\\[error GOTCHA!]]]} this will be echoed
      
      this will be echoed
      
      
      Make the index:
      
      
      % auto_mkindex /tmp /tmp/test.tcl
      
      
      Invoke protclsh again, and add /tmp to auto_path, then try to execute
      
      the above perfectly legitimate commands:
      
      
      protclsh82
      
      % lappend auto_path /tmp;\
      
        {ugly* $procname [error GOTCHA!]} this will be echoed
      
      error while autoloading "ugly* $procname [error GOTCHA!]": GOTCHA!
      
      
      ObservedBehavior:
      
      With a bit of tinkering, assorted other effects are possible: complaints
      
      about undefined variables, mismatched brackets, and just plain return to
      
      Unix shell if a procedure name is {[exit]}.
      
      
      DesiredBehavior:
      
      None of the above.
      
      
      Patch:
      
      *** old/auto.tcl        Thu Jul 29 15:46:09 1999
      
      --- ./auto.tcl  Thu Jul 29 16:34:54 1999
      
      ***************
      
      *** 463,472 ****
      
            }
      
      
            if {[namespace qualifiers $name] == ""} {
      
      !         return [namespace tail $name]
      
            } elseif {![string match ::* $name]} {
      
      !         return "::$name"
      
            }
      
            return $name
      
        }
      
      
      --- 463,477 ----
      
            }
      
      
            if {[namespace qualifiers $name] == ""} {
      
      !         set name [namespace tail $name]
      
            } elseif {![string match ::* $name]} {
      
      !         set name "::$name"
      
            }
      
      + 
      
      +     # Since auto_mkindex_parser::mkindex has escaped all $ characters, we
      
      +     # should restore the correct procedure names:
      
      +     regsub -all -- {\\\$} $name {$} name
      
      + 
      
            return $name
      
        }
      
      ***************
      
      *** 311,318 ****
      
      --- 311,324 ----
      
            foreach name $nameList {
      
              if {[info exists auto_index($name)]} {
      
                  uplevel #0 $auto_index($name)
      
      +           # Command names may contain weird characters (e.g. []) that may
      
      +           # prevent a successful match, so use a trick and if 'info command'
      
      +           # fails, query the current namespace for the origin of the command.
      
      +           #
      
                  if {[info commands $name] != ""} {
      
                      return 1
      
      +           } elseif {[namespace which -command $name] != ""} {
      
      +               return 1
      
                  }
      
              }
      
            }
      
      ***************
      
      *** 353,359 ****
      
                  set error [catch {
      
                      set id [gets $f]
      
                      if {$id == "# Tcl autoload index file, version 2.0"} {
      
      !                   eval [read $f]
      
                      } elseif {$id == \
      
                          "# Tcl autoload index file: each line identifies a Tcl"} {
      
                          while {[gets $f line] >= 0} {
      
      --- 359,367 ----
      
                  set error [catch {
      
                      set id [gets $f]
      
                      if {$id == "# Tcl autoload index file, version 2.0"} {
      
      !                   # eval [read $f] fails in various interesting ways, but
      
      !                   # sourcing the file directly seems to work just fine.
      
      !                   source [file join $dir tclIndex]
      
                      } elseif {$id == \
      
                          "# Tcl autoload index file: each line identifies a Tcl"} {
      
                          while {[gets $f line] >= 0} {
      
      
      PatchFiles:
      
      auto.tcl and init.tcl
      
      
      
      
      I am unable to reproduce this bug in 8.3b2 (although I could in 8.2.1).  There have been several changes to the auto.tcl and init.tcl files in that time, as well as many changes to the core itself, so I'm not certain when specifically this bug was fixed.
      
      However, investigating this bug did expose a new bug in the auto loader, relating to the use of * and [] in the proc name.  Because of the matching technique used to determine if the command had been successfully loaded, those characters were being interpreted as glob-style specifiers, which was causing the auto loader to think that the command had not been loaded when it actually had been.  I fixed this bug for 8.3.
      
      - eric
      
      -- 01/28/2000 ericm
      
      On further consideration, it seems that I misspoke.  The error does exist, albeit in a slightly altered form.  If you have code such as:
      proc {\\$foobar} {} {}
      
      You will see this problem.  Realistically, however, people are not going to make procedure names like this, and the auto indexing procedures were not designed to handle this sort of case.  If you need to index a file with procedure names like that, perhaps you could use auto_mkindex_old, which uses a less sophisticated but in some cases (like this one) more robust algorithm.
      
      - eric
      
      -- 01/28/2000 ericm
      
      
      
    4. foundin initialized to: "obsolete: 8.2b1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "56. LibTomMath"
    10. title initialized to:
      FIX for auto_mkindex/auto_load bugs on funny procedure names
      
    11. type initialized to: "Bug"
  2. Ticket change [a8c474e46d] (rid 99045) by welch on 2000-10-26 08:30:15:

    1. closedate changed to: "2000-10-26T01:30:15"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [ec884095d7] (rid 103722) by dgp on 2001-04-06 02:06:07:

    1. closedate changed to: "2001-04-05T19:06:07"
    2. closer changed to: "dgp"
    3. subsystem changed to: "38. Init - Library - Autoload"
  4. Ticket change [d5c9c44dc5] (rid 123694) by dgp on 2003-09-23 11:22:29:

    1. assignee changed to: "dgp"
    2. foundin changed to: "obsolete: 8.4.4"
    3. icomment:
      Logged In: YES 
      user_id=80530
      
      
      Re-opened.
      
      ericm's [info commands] -> [namespace which -command]
      fix was a good one, but he should have applied it
      throughout, not in only one place.
      
      Now that I found this report, it seems
      the bug should also remain open until
      the [auto_mkindex] issue is resolved.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. status changed to: "Open"
    7. username: "dgp"
  5. Ticket change [4222de3349] (rid 116310) by dgp on 2003-09-23 11:51:25:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      committed the expanded fix
      for 8.4.5+
      
      keeping open at low priority
      as a reminder to examine
      the [auto_mkindex] issue.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  6. Ticket change [e2c273d652] (rid 259743) by serhiy.storchaka on 2026-10-21 10:03:39:

    1. icomment:
      The [info commands] problem was fixed by [56990efadd] (8.3.0) and [dbc5f2a73f]/[2ce276bdca] (8.4.5). The auto_mkindex part kept open here works too: the reported procedure names are indexed and autoloaded correctly from 8.4.2 through 9.1. Closing.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"