Artifacts Associated With Ticket e87bcf819f
Ticket change [abebe37771] (rid 162558) by dgp on 2018-04-22 19:10:03:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Contrast these two: % proc demo {} { array set a {m 1 n 2 o 3 p 4} try { array for {k v} a {unset a(n)} } on error {m} { puts "ERROR: $m" } finally { puts [array get a] } } % demo ERROR: array changed during iteration p 4 m 1 o 3 % proc demo {} { array set a {m 1 n 2 o 3 p 4} upvar 0 a(n) l try { array for {k v} a {catch {unset l}} } on error {m} { puts "ERROR:$m" } finally { puts [array get a] } } % demo p 4 m 1 o 3 - is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "07. Variables"
- title initialized to:
[array for] fails to detect array change made through upvar
- type initialized to: "Bug"
Ticket change [81b9d0dc8c] (rid 162559) by dgp on 2018-04-22 19:13:11:
- icomment:
Because this evades the protection against using a Tcl_HashSearch after the hash table has changed, it is likely this can be used to create segfaults.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [da4ded8276] (rid 162560) by dgp on 2018-04-22 19:13:46:
- icomment:
The same failure probably exists in the [array startsearch], etc commands.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [e1675ea83d] (rid 162568) by dgp on 2018-04-22 23:11:51:
- assignee changed to: "dkf"
- icomment:
Candidate fix on branch bug-e87bcf819f. dkf should comment on the changes made to TclOOBasic.c
- login: "dgp"
- mimetype: "text/plain"
Ticket change [6f591e569c] (rid 162728) by dgp on 2018-04-30 11:56:54:
- icomment:
Note that the machinery created here might be useful in fixing the very old bug/RFE https://core.tcl-lang.org/tcl/tktview?name=572889 as well.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [cd965326b6] (rid 162862) by dkf on 2018-05-07 15:06:16:
- icomment:
What I find interesting is that the [<tt>unset l</tt>] doesn't change the structure of the array. It's because there's still a reference to it (from the <tt>l</tt> variable) but it's still unexpected to anyone who isn't experienced with Tcl's guts.
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"
- icomment:
Ticket change [0b62fb06fe] (rid 162863) by dkf on 2018-05-07 15:11:01:
- icomment:
<tt>Xref: <a href="/tcl/timeline?r=bug-e87bcf819f">bug-e87bcf819f</a></tt>
- login: "dkf"
- mimetype: "text/html"
- username: "dkf"
- icomment:
Ticket change [d6c5384582] (rid 162864) by dkf on 2018-05-07 15:19:26:
- icomment:
The changes to tclOOBasic.c look OK to me. They won't interfere with TIP 500.
- login: "dkf"
- mimetype: "text/html"
- icomment:
Ticket change [5c8f767629] (rid 162867) by dkf on 2018-05-07 15:56:29:
- icomment:
And the bug is that the unset isn't killing the searches, and that's because the variable link is meaning that we're arriving at the element (which knows that it is in a TclVarHashTable) without going back to check if this makes things become invalidated. Which it can't do because we don't currently keep a pointer to the containing variable in the TclVarHashTable (the pointer could be NULL for non-array use cases, I guess). I don't know what the consequences of keeping such a pointer would be, apart from a small amount of extra memory usage. <p> The first option is correct; an error <i>should</i> be thrown by <tt>array for</tt> on internal modification.
- login: "dkf"
- mimetype: "text/html"
- icomment:
Ticket change [ef3f21f132] (rid 259700) by serhiy.storchaka on 2026-10-21 10:03:36:
- icomment:
Fixed in 9.0.0 as a side effect of TIP #634 ([a3a43c9363]): element hash tables now point to their array, so unsetting an element through an upvar link ends active searches and [array for] reports the change. Branch bug-e87bcf819f was not needed.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- icomment:
Ticket change [b08c22c457] (rid 259997) by serhiy.storchaka on 2026-10-22 17:19:29:
- closedate changed to: "2461334.919170174"
- closer changed to: "serhiy.storchaka"
- login: "serhiy.storchaka"