Overview
| Artifact ID: | 728537cd4cc4752f522f085c028069a84b6afa5a |
|---|---|
| Ticket: | 3598580fffffffffffffffffffffffffffffffff
Tcl_ListObjReplace may release deleted elements too early |
| User & Date: | apnadkarni on 2012-12-28 11:18:13 |
Changes
- icomment:
In response to dgp's request, here is a critcl code fragment to illustrate the problem. As said earlier, because of ref counts, not clear how to demo from a script level. critcl::ccommand crash {} { Tcl_Obj *objP; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "LIST"); return TCL_ERROR; } /* Just demo - No error checking */ if (Tcl_IsShared(objv[1])) { Tcl_SetResult(interp, "Need unshared list obj for test", TCL_STATIC); return TCL_ERROR; } /* Nonsensical but legal */ Tcl_ListObjIndex(interp, objv[1], 1, &objP); Tcl_ListObjReplace(interp, objv[1], 1, 2, 1, &objP); Tcl_SetObjResult(interp, objv[1]); return TCL_OK; } The following will then result in a panic on windows: C:\src\tarray\src>tclsh86t % proc history args {} % crash invalid command name "crash" % source tarray.critcl % crash wrong # args: should be "crash LIST" % set v [list ghi fgr tke] ghi fgr tke % crash $v[set v ""] ghi fgr % set x "afasdf" <Panic> Tracing verifies that the second element is freed via TclpFree, put on the cache and then added back to the list, then assigned to x - login: "apnadkarni"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "apnadkarni"