Skip to content
Tcl Source Code History Of Ticket 554117edde
Login

History Of Ticket 554117edde

Artifacts Associated With Ticket 554117edde

  1. Ticket change [5d6b49a2f1] (rid 179106) by sebres on 2020-02-10 16:35:07:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      Current implementation of <code>Tcl_SaveInterpState/Tcl_RestoreInterpState</code> does not consider (legacy) copy of interpreter state (errorInfo/errorCode variables), which can produce unexpected behavior overwriting both values like in following example:
      <code><pre style="padding-left:10pt">
      if {[catch {
         ... same code X producing error ...
      } msg]} {
         log INFO "unexpected error in block X: $msg"
         log DEBUG $::errorCode $::errorInfo
      }
      </pre></code>
      if routine log (can evaluate something in interp and even generate temporary errors) does "safe" handling to save interp state (uses Tcl_SaveInterpState/Tcl_RestoreInterpState), it can overwrite <code>::errorInfo</code> and <code>::errorCode</code> or rather does not restore both properly, if some <code>Tcl_ResetResult</code> (called internally) resets interim <code>iPtr->errorInfo</code> and <code>iPtr->errorCode</code> to NULL.
      
      This causes that system traces observing <code>::errorInfo</code> and <code>::errorCode</code> do nothing (because iPtr states are NULL) and both variables remain overwritten values.
      
      Although I know that <code>::errorInfo</code> and <code>::errorCode</code> are legacy either and one should rather use option dictionary (second parameter after msg variable in catch), but <code>Tcl_SaveInterpState/Tcl_RestoreInterpState</code> are pretty unusable together with any kind of evaluation (especially because <code>Tcl_ResetResult</code> is involved in-between internally, and it is almost always the case).
      
      The error is initially noticed in [https://github.com/sebres/tclclockmod/issues/19#issuecomment-582639778|GH/sebres/tclclockmod/issues/19#issuecomment-582639778].
      
      But now I have a branch with test cases illustrating that.
      
    5. is_private initialized to: "0"
    6. login: "sebres"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Minor"
    10. status initialized to: "Open"
    11. submitter initialized to: "sebres"
    12. subsystem initialized to: "45. Parsing and Eval"
    13. title initialized to:
      Tcl_SaveInterpState/Tcl_RestoreInterpState are not usable to save interpreter state (error info/code)
      
    14. type initialized to: "Bug"
  2. Ticket change [733ee1b91d] (rid 179112) by sebres on 2020-02-10 16:44:27:

    1. comment changed to:
      Current implementation of <code>Tcl_SaveInterpState/Tcl_RestoreInterpState</code> does not consider (legacy) copy of interpreter state (errorInfo/errorCode variables), which can produce unexpected behavior overwriting both values like in following example:
      <code><pre style="padding-left:10pt">
      if {[catch {
         ... same code X producing error ...
      } msg]} {
         log INFO "unexpected error in block X: $msg"
         log DEBUG $::errorCode $::errorInfo
      }
      </pre></code>
      if routine log (can evaluate something in interp and even generate temporary errors) does "safe" handling to save interp state (uses Tcl_SaveInterpState/Tcl_RestoreInterpState), it can overwrite <code>::errorInfo</code> and <code>::errorCode</code> or rather does not restore both properly, if some <code>Tcl_ResetResult</code> (called internally) resets interim <code>iPtr->errorInfo</code> and <code>iPtr->errorCode</code> to NULL.
      
      This causes that system traces observing <code>::errorInfo</code> and <code>::errorCode</code> do nothing (because iPtr states are NULL) and both variables remain overwritten values.
      
      Although I know that <code>::errorInfo</code> and <code>::errorCode</code> are legacy either and one should rather use option dictionary (second parameter after msg variable in catch), but <code>Tcl_SaveInterpState/Tcl_RestoreInterpState</code> are pretty unusable together with any kind of evaluation (especially because <code>Tcl_ResetResult</code> is involved in-between internally, and it is almost always the case).
      
      The error is initially noticed in [https://github.com/sebres/tclclockmod/issues/19#issuecomment-582639778|GH/sebres/tclclockmod/issues/19#issuecomment-582639778].
      
      But now I have a branch [/timeline?r=bug-554117edde|bug-554117edde] with test cases [95db6756e8bd9f96] illustrating that.
      
    2. icomment:
      As one can see both 1.9.* test cases fails:
      <code><pre style="padding-left:10pt">
      ==== result-1.9.1 Tcl_SaveInterpState: "safe" eval without modifying states FAILED
      ...
      ---- Result was:
      <b style="color:red">{UNEXPERR INVISIBLE} {ERROR in safe block}</b>
      ---- Result should have been (exact matching):
      {EXPERR TEST-ERROR} {ERROR expected error}
      ==== result-1.9.1 FAILED
      
      
      ==== result-1.9.2 Tcl_SaveInterpState: nested save state does not modify error info/code FAILED
      ...
      ---- Result was:
      <b style="color:red">0 {UNEXPERR INVISIBLE} {ERROR in safe block}</b>
      ---- Result should have been (exact matching):
      0 {EXPERR TEST-ERROR} {ERROR expected error}
      ==== result-1.9.2 FAILED
      </pre></code>
      
    3. login: "sebres"
    4. mimetype: "text/x-fossil-wiki"
  3. Ticket change [4427912eac] (rid 179120) by sebres on 2020-02-10 16:52:21:

    1. icomment:
      Fixed in [9cace6cc78], tests passed.<br/>
      I guess it should be cherry-picked to 8.5 as well.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Pending"
  4. Ticket change [943348dc93] (rid 218022) by jan.nijtmans on 2023-09-12 13:40:37:

    1. icomment:
      I'm seeing 3 failing test-cases:
      <pre>
      init.test
      
      
      ==== init-0.1 no error on initialization phase (init.tcl) FAILED
      ==== Contents of test case:
      
          child eval {
      	list [set v [info exists ::errorInfo]]  [if {$v} {set ::errorInfo}]  [set v [info exists ::errorCode]]  [if {$v} {set ::errorCode}]
          }
      
      ---- Result was:
      0 {} 1 {}
      ---- Result should have been (exact matching):
      0 {} 0 {}
      ==== init-0.1 FAILED
      
      ioCmd.test
      
      
      ==== iocmd-21.8 chan create, initialize failed, bad result, not a list FAILED
      ==== Contents of test case:
      
          proc foo {args} {return "\{"}
          catch {chan create {r w} foo} msg
          rename foo {}
          set ::errorInfo
      
      ---- Result was:
      wrong # args: should be "::foo"
          while executing
      "::foo initialize rc3 {read write}"
          (chan handler subcommand "initialize")
          invoked from within
      "chan create {r w} ::foo"
          invoked from within
      "chan create {r w} foo"
      ---- Result should have been (glob matching):
      chan handler "foo initialize" returned non-list: *
      ==== iocmd-21.8 FAILED
      
      ioTrans.test
      
      
      ==== iortrans-2.7 chan push, initialize failed, bad result, not a list FAILED
      ==== Contents of test case:
      
          proc foo {args} {return "\{"}
          catch {chan push [tempchan] foo}
          return $::errorInfo
      
      ---- Result was:
      wrong # args: should be "::foo"
          while executing
      "::foo initialize rt2 {read write}"
          (chan handler subcommand "initialize")
          invoked from within
      "chan push [tempchan] ::foo"
          ("uplevel" body line 3)
          invoked from within
      "uplevel 1 $script"
          invoked from within
      "chan push [tempchan] foo"
      ---- Result should have been (glob matching):
      chan handler "foo initialize" returned non-list: *
      ==== iortrans-2.7 FAILED
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"