Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[try] interaction with local variable names produces segmentation fault

Closed / Fixed45b9faf103f2fd0f7c4a69606b358bb68dbd2596Created 8 years agoUpdated 8 years ago
Descriptionwiki2019-04-08 09:38:22
The following script produces a segmentation fault:

proc main {} {
    eval {
        try {
            lindex 5
        } on ok res {} 
    }
    puts $res
}
main

The issue is:

tclCmdMZ.c:TryPostBody extracts a variable name from a Tcl_Obj, causing a list internal representation to be created on that Tcl_Obj, and the original value of that Tcl_Obj to become the first item in the list, with a refCount of 1.
On the next line, Tcl_ObjSetVar2 is called, and TclObjLookupVarEx subsequently obtains that same Tcl_Obj from the cache of local variable names and frees that same list internal representation.
At this point, part1Ptr is a reference to that freed Tcl_Obj.
sebreswiki2019-04-08 09:59:09

See also related ticket [578155d5a1].

I'm for solution with TCL_OWN_OBJREF flag, which is a year ago merged in my own branches and it works there without any issue.

pooryorickwiki2019-04-08 13:04:05

Fixed in [4100488a3ca38abf].

sebreswiki2019-04-08 15:37:16

closed in [e62a48e964]

Log in (anonymous is fine) to add a comment.