Overview
| Artifact ID: | 5d6b49a2f144b425ff2456ebdad077f19c3af1f670b92d8fd806605d78bbbc64 |
|---|---|
| Ticket: | 554117eddec7220f1cda04c16cc45a77d6c175e0
Tcl_SaveInterpState/Tcl_RestoreInterpState are not usable to save interpreter state (error info/code) |
| User & Date: | sebres on 2020-02-10 16:35:07 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- 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 with test cases illustrating that. - is_private changed to: "0"
- login: "sebres"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "sebres"
- subsystem changed to: "45. Parsing and Eval"
- title changed to:
Tcl_SaveInterpState/Tcl_RestoreInterpState are not usable to save interpreter state (error info/code)
- type changed to: "Bug"