Artifacts Associated With Ticket 2662380
Ticket change [cd50c22409] (rid 95869) by a3a3el on 2009-03-04 17:01:47:
- assignee initialized to: "dgp"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The following can crash 8.4, 8.5 and 8.6: array set a [list] trace variable a w unset_key proc unset_key { var key op } { puts stderr "$var, $key, $op" global a if { [info exists a($key)] } { puts stderr "Unsetting a($key)." unset a($key) } else { puts stderr "Cannot unset a($key)." } } append a(test) one two Since 8.4, Tcl_AppendObjCmd has stopped calling Tcl_ObjSetVar2, and calls TclPtrSetVar instead. However, although TclPtrSetVar returns iPtr->emptyObj if the variable has been unset by a trace, Tcl_AppendObjCmd is still checking for NULL, and so attempts to append the next argument. I've attached patches for the 8.4 and 8.5 branches, and the trunk. Az. - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "a3a3el"
- subsystem initialized to: ""
- title initialized to: "Bug in append"
- type initialized to: "Bug"
Ticket change [fac61244ca] (rid 91940) by a3a3el on 2009-03-05 00:01:47:
- icomment:
File Added - 316175: tclVar-8.4.diff
- login: "a3a3el"
- mimetype: "text/plain"
- username: "a3a3el"
- icomment:
Add attachment "tclVar-8.4.diff" [6758ac82ef] (rid 102886) by a3a3el on 2009-03-05 00:01:47.
Ticket change [1665e93b58] (rid 124712) by a3a3el on 2009-03-05 00:02:08:
- icomment:
File Added - 316176: tclVar-8.5.diff File Added: tclVar-8.5.diff
- login: "a3a3el"
- mimetype: "text/plain"
- username: "a3a3el"
- icomment:
Add attachment "tclVar-8.5.diff" [5206d80f34] (rid 126237) by a3a3el on 2009-03-05 00:02:08.
Ticket change [401cb374e2] (rid 121573) by a3a3el on 2009-03-05 00:02:24:
- icomment:
File Added - 316178: tclVar-trunk.diff File Added: tclVar-trunk.diff
- login: "a3a3el"
- mimetype: "text/plain"
- username: "a3a3el"
- icomment:
Add attachment "tclVar-trunk.diff" [8c4e129dff] (rid 127723) by a3a3el on 2009-03-05 00:02:24.
Ticket change [3a298c87b7] (rid 112516) by dkf on 2009-03-05 00:04:36:
- priority changed to: "9 Immediate"
Ticket change [061cdc6b41] (rid 89161) by dkf on 2009-04-05 00:34:36:
- icomment:
data_type - 110894
- login: "dkf"
- mimetype: "text/plain"
- subsystem changed to: "46. Traces"
- username: "dkf"
- icomment:
Ticket change [aaf7ebd722] (rid 101013) by dkf on 2009-04-05 00:34:52:
- foundin changed to: "obsolete: 8.4.19"
Ticket change [004f36d349] (rid 119296) by dgp on 2009-04-08 02:25:39:
- icomment:
I see no crash. On 8.4 I see: a, test, w Unsetting a(test). a, test, w Cannot unset a(test). On Tcl 8.5 and HEAD I see an uncaught errors, but not always the same one (!). Either : a, test, w Unsetting a(test). can't set "a(test)": upvar refers to element in deleted array while executing "append a(test) one two" (file "/home/dgp/2662380.tcl" line 20) or this: a, test, w Unsetting a(test). can't set "a(test)": upvar refers to variable in deleted namespace while executing "append a(test) one two" (file "/home/dgp/2662380.tcl" line 20) - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [98aff6c411] (rid 110653) by dkf on 2009-04-08 03:12:25:
- priority changed to: "8"
Ticket change [eb7a2609f1] (rid 103549) by dgp on 2009-04-08 20:32:48:
- icomment:
Relevant tests: append-7.1 appendComp-7.1 namespace-8.6 trace-16.8,9,10,13,14
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [31ead71b26] (rid 93517) by dgp on 2009-04-08 21:42:01:
- assignee changed to: "msofer"
- icomment:
I modified the test script so that the "Unsetting" messages reports the value of the variable about to be unset. Then testing on Tcl releases 7.6p2 and 8.3.5, I see they agree on this output: a, test, w Unsetting a(test) = one. a, test, w Unsetting a(test) = two. Without thinking too deeply about it, I admit, that output also makes sense to me. [append] can operate on a name of a non-existent variable, creating the variable by making the appending write to it. Write traces come after the writing, so at that point the variable exists, and the trace can unset it. We end up back where we started with no existing variable. Multiple arguments to append just means we repeat the cycle. Appears this report is exposing some flaws in some of the varName resolution caching machinery that's come in releases 8.4 and later. Fixing that right may take some time and thought (*), and since it appears the claims of "crashes" are incorrect, I'll leave this one to come back to. The submitted patches may well be the right answer, I'm not sure yet, but the flaws exposed are broader and deeper, so I'd prefer to be more certain about a more complete fix. (*) or at least some input from msofer. :)
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
Ticket change [287d207fb1] (rid 88707) by msofer on 2011-04-12 09:30:37:
- foundin changed to: "obsolete: 8.5.9"
- icomment:
Crashes HEAD but not core-8-5-branch as of today. Valgrind however still dislikes it in 8.5
- login: "msofer"
- mimetype: "text/plain"
- priority changed to: "9 Immediate"
- username: "msofer"
Ticket change [97b0155ab3] (rid 110481) by msofer on 2011-04-12 18:39:41:
- icomment:
The "gross change in write traces" covers 2 cases: * trace undefined the var: in that case, TclPtrSetVar should just clear the var and return NULL * trace converted the var to an array: so what do we do now? What should append/set/etc return? In 8.4: % trace add variable x write foo % proc foo {name args} {upvar 1 $name x; unset x; set x(1) 1} % append x 2 % set x can't read "x": variable is array % parray x x(1) = 1 - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [85a9c04ab3] (rid 131355) by msofer on 2011-04-13 20:36:26:
- icomment:
fixed in all 3 branches
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [6824a85e14] (rid 103014) by msofer on 2011-04-13 20:36:28:
- closedate changed to: "2011-04-13T13:36:28"
- closer changed to: "msofer"
- icomment:
allow_comments - 1
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "msofer"