Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2e1be563756991a0c9e75ad47d1f156759698db01e0351e433fcd6e18f488b61
Ticket: 775ee885603d3d09b5984b1579630e9786f78928
upvar (used with wrong level) causes a segfault
User & Date: sebres on 2019-09-06 21:06:14
Changes

  1. closedate changed to: "2458733.3793355"
  2. closer changed to: "sebres"
  3. icomment:
    I found another solution for second part (invalid level used in "bad level" message, if relative level out of frames) as in branch "bug-775ee88560", which is simplier, also TIP#515-conform as well as binary compatible.<br/>
    Fixed now, so I'll close this.
    
    BTW. I fixed another wrong case across all branches (so TclGetFrame and Tcl_UpVar2 are more consistent to TclObjGetFrame now, as regards the error message).
    If frameName (actual level) does not contain a real level (#0 or 1) historically TclGetFrame and Tcl_UpVar2 use current level - 1, so to put supplied name in case of bad level (error at top - 1) was wrong but also not consistent with TclObjGetFrame.<br/>
    The fix affects only the error message (and test "upvar-9.1").<br/>
    Although I don't think it is good at all to accept wrong level, but Tcl_UpVar2  works so very very long time.<br/>
    
    Just I don't think scenarios covered with "upvar-9.1.1", "upvar-9.3" etc as well as following are good at all:
    <pre>
      apply {{} {testupvar "this is a bad level" a {} x local; puts OK}}
    </pre>
    In my opinion reasonable would be to allow Tcl_UpVar2 only "#0", "1", NULL (and may be "") as argument frameName, and bad level in other case, but at the moment (as one can see above and in mentioned test cases) it allows any bad value if called from level > 0, and fails only if called at top-level (so all values were invalid).
    
  4. login: "sebres"
  5. mimetype: "text/x-fossil-wiki"
  6. resolution changed to: "Fixed"
  7. status changed to: "Closed"