Skip to content
Tcl Source Code History Of Ticket afa8c9
Login

History Of Ticket afa8c9

Artifacts Associated With Ticket afa8c9

  1. Ticket change [d4bcebc953] (rid 258533) by serhiy.storchaka on 2026-10-17 10:51:12:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. comment initialized to:
      When an execution trace (enter or leave) raises an error, the errorInfo has the wrong line number and loses the frame of the traced command. File <tt>x.tcl</tt>:
      
      <verbatim>
      proc p args {}
      trace add execution p leave {error boom;#}
      
      p
      </verbatim>
      
      <nowiki>[catch {source x.tcl} m o; puts [dict get $o -errorinfo]]</nowiki> in 8.6.1 and later (also 9.0.5 and main):
      
      <verbatim>
      boom
          while executing
      "error boom"
          (leave trace on "p")
          (file "x.tcl" line 1)
          invoked from within
      "source x.tcl"
      </verbatim>
      
      8.5.19 says <tt>(file "x.tcl" line 4)</tt>, with <tt>invoked from within "p"</tt> before it (8.6.0 also says line 4, but drops the error message of the trace, see [2438181fff]). The same happens with <tt>enter</tt> traces, in proc bodies (<tt>(procedure "q" line 1)</tt>) and in <nowiki>[eval]</nowiki> bodies. Variable traces are not affected (<tt>(write trace on "v")</tt>, <tt>invoked from within "set v 1"</tt>, correct line).
      
      Cause: the fix for [010f4162ef] ([f0e808cc64], 8.6.1) appends <tt>(enter/leave trace on "...")</tt> in <tt>TEOV_RunEnterTraces()</tt> / <tt>TEOV_RunLeaveTraces()</tt> in <tt>generic/tclBasic.c</tt> and then sets <tt>ERR_ALREADY_LOGGED</tt>. That flag makes the caller skip <tt>TclLogCommandInfo()</tt>, which is where the line number of the failing command is computed and the <tt>invoked from within</tt> frame is added, so the line stays 1.
      
      A fix would need to keep that logging in the caller while still avoiding the doubled <tt>-errorstack</tt> level from [010f4162ef].
      
    3. foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
    4. login: "serhiy.storchaka"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. severity initialized to: "Minor"
    8. status initialized to: "Open"
    9. subsystem initialized to: "46. Traces"
    10. title initialized to:
      Error in an execution trace reports line 1 and loses the traced command's frame in errorInfo
      
    11. type initialized to: "Bug"
  2. Ticket change [ea23b02d8c] (rid 258579) by serhiy.storchaka on 2026-10-17 12:10:54:

    1. icomment:
      Proposed fix in branch [/timeline?r=trace-error-keep-frame|trace-error-keep-frame]: the trace code sets a new flag <tt>ERR_STACK_LOGGED</tt> instead of <tt>ERR_ALREADY_LOGGED</tt>, so <tt>TclLogCommandInfo()</tt> still adds the frame and line number to errorInfo and only skips the errorstack level (the doubled level of [010f4162ef] does not come back, error-4.8 passes). Tests trace-bug-afa8c9f5bb-1 and -2.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [e054356f5f] (rid 259532) by serhiy.storchaka on 2026-10-20 18:11:29:

    1. submitter changed to: "serhiy.storchaka"
  4. Ticket change [82c415b0ef] (rid 263416) by jan.nijtmans on 2026-11-27 15:26:47:

    1. assignee changed to: "jan.nijtmans"
    2. closer changed to: "nobody"
    3. comment changed to:
      When an execution trace (enter or leave) raises an error, the errorInfo has the wrong line number and loses the frame of the traced command. File <tt>x.tcl</tt>:
      
      <verbatim>
      proc p args {}
      trace add execution p leave {error boom;#}
      
      p
      </verbatim>
      
      <nowiki>[catch {source x.tcl} m o; puts [dict get $o -errorinfo]]</nowiki> in 8.6.1 and later (also 9.0.5 and main):
      
      <verbatim>
      boom
          while executing
      "error boom"
          (leave trace on "p")
          (file "x.tcl" line 1)
          invoked from within
      "source x.tcl"
      </verbatim>
      
      8.5.19 says <tt>(file "x.tcl" line 4)</tt>, with <tt>invoked from within "p"</tt> before it (8.6.0 also says line 4, but drops the error message of the trace, see [2438181fff]). The same happens with <tt>enter</tt> traces, in proc bodies (<tt>(procedure "q" line 1)</tt>) and in <nowiki>[eval]</nowiki> bodies. Variable traces are not affected (<tt>(write trace on "v")</tt>, <tt>invoked from within "set v 1"</tt>, correct line).
      
      Cause: the fix for [010f4162ef] ([f0e808cc64], 8.6.1) appends <tt>(enter/leave trace on "...")</tt> in <tt>TEOV_RunEnterTraces()</tt> / <tt>TEOV_RunLeaveTraces()</tt> in <tt>generic/tclBasic.c</tt> and then sets <tt>ERR_ALREADY_LOGGED</tt>. That flag makes the caller skip <tt>TclLogCommandInfo()</tt>, which is where the line number of the failing command is computed and the <tt>invoked from within</tt> frame is added, so the line stays 1.
      
      A fix would need to keep that logging in the caller while still avoiding the doubled <tt>-errorstack</tt> level from [010f4162ef].
      
    4. icomment: "Merged to [f158fb9ffa|trunk]"
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Pending"