Artifacts Associated With Ticket 2889293
Ticket change [84f419cfcc] (rid 131239) by mistachkin on 2009-10-30 07:55:47:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
It seems the act of checking for an array element has the effect of deleting pending array searches. Why does INST_EXIST_STK in TEBC call TclObjLookupVarEx with createPart2 non-zero? Example: set s [array startsearch tcl_platform] # # NOTE: Try this test with and without this [puts] line commented. # puts stdout [info exists tcl_platform([clock seconds])]; # improperly invalidates array search. set result [list] while {[array anymore tcl_platform $s]} { if {[array nextelement tcl_platform $s] eq "user"} then { lappend result user } } set result; # should be "user" catch {array donesearch tcl_platform $s} catch {unset -nocomplain result s} - foundin initialized to: "obsolete: 8.6b1.1"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "mistachkin"
- subsystem initialized to: "47. Bytecode Compiler"
- title initialized to: "[info exists array(elem)] deletes array searches"
- type initialized to: "Bug"
Ticket change [248e4dd6db] (rid 131124) by msofer on 2009-10-30 17:15:54:
- assignee changed to: "dkf"
- icomment:
The BC implementation has to mimic exactly the non-compiled implementation. As [info exists] triggers read traces on the array and the traces could well create new elements, the effect on searches is inevitable (or at least very hard to avoid). The comments at the start of TclVarTraceExists attempt an explanation: /* * The choice of "create" flag values is delicate here, and matches the * semantics of GetVar. Things are still not perfect, however, because if * you do "info exists x" you get a varPtr and therefore trigger traces. * However, if you do "info exists x(i)", then you only get a varPtr if x * is already known to be an array. Otherwise you get NULL, and no trace * is triggered. This matches Tcl 7.6 semantics. */ - login: "msofer"
- mimetype: "text/plain"
- subsystem changed to: "17. Commands I-L"
- username: "msofer"
Ticket change [7e9f6439fc] (rid 97449) by ferrieux on 2009-10-30 23:49:03:
- icomment:
Naively, I'd associate search cancellation with _writing_ into the array. Why are we being so shy ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [c3dc812e1e] (rid 111744) by hobbs on 2009-10-30 23:56:47:
- icomment:
Because traces can modify anything at read or write time would be my guess.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment:
Ticket change [1971ace222] (rid 122807) by ferrieux on 2009-10-31 00:03:12:
- icomment:
Loud and clear, but why not wait for the code to actually do the modification instead of bailing out on mere suspicion ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [81bdbc773c] (rid 117095) by mistachkin on 2009-11-02 10:04:15:
- icomment:
We should either fix the underlying issue (phantom array elements being created and destroyed, invalidating array searches) or at least document it. My opinion is that we should fix it if at all possible as having [info exists] invalidate array searches on any array element (i.e. this has nothing to do with env) violates the Principle of Least Surprise.
- login: "mistachkin"
- mimetype: "text/plain"
- username: "mistachkin"
- icomment:
Ticket change [b1af29de4a] (rid 98187) by dkf on 2009-11-02 16:01:13:
- icomment:
I agree in principle, but only if we can figure out a way to not cause any other surprises. Since this has been this way for a long time, there's no need to hurry. Longer term, I want to remove the assumption that arrays use hash tables so that we can, for example, map more directly onto getenv/setenv (or a BLT vector or a metakit DB) without having a spare-wheel hash in between. That's not about to happen for 8.6...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [1a969d80b5] (rid 123006) by dkf on 2011-10-01 15:02:06:
- assignee changed to: "msofer"
- icomment:
For the record, TEBC sets createPart2 because that's what the code I was converting from did (i.e., I didn't change [info exists] at all). I do not know if that's the right thing to do. There does seem to be some complexity with traces, i.e., where a whole array trace creates the element. :-( Assigning the master of variables.
- login: "dkf"
- mimetype: "text/plain"
- subsystem changed to: "07. Variables"
- username: "dkf"
Ticket change [88ea31b6aa] (rid 131939) by pooryorick on 2013-02-14 13:18:01:
- icomment:
I've made some changes to TclCallVarTraces, which allows TclVarTraceExists to set createPart2 to 0 when calling TclLookupVar. This fixes the underlying issue described by mistachkin. The changes can be found here: https://ynform.org/fossil/tcl/info/45968549a8
- login: "pooryorick"
- mimetype: "text/plain"
- username: "pooryorick"
- icomment: