Artifacts Associated With Ticket b343fe8656c16b2e
Ticket change [6e989b5abf] (rid 235500) by apnadkarni on 2024-11-27 10:38:08:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized to:
The **Incompatibility** section in [TIP 636](https://core.tcl-lang.org/tips/doc/trunk/tip/636.md) does not seem to be documented afaict. It should probably to added to the ListObj.3 manpage as `Tcl_ListObjIndex` is impacted.
- foundin initialized to: "9.0"
- is_private initialized to: "0"
- login: "apnadkarni"
- priority initialized to: "5 Medium"
- private_contact initialized to: "9546e9877f1a8899e25a89082561ee694e7fb402"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "apnadkarni"
- subsystem initialized to: "14. List Object"
- title initialized to: "Tcl_ListObjIndex incompatibility not documented"
- type initialized to: "Bug"
Ticket change [854593f533] (rid 235501) by apnadkarni on 2024-11-27 10:38:36:
- assignee changed to: "griffin"
- login: "apnadkarni"
- mimetype: "text/plain"
- title changed to:
TIP 636 Tcl_ListObjIndex incompatibility not documented
Ticket change [0c80b3c4a6] (rid 235557) by griffin on 2024-11-28 19:50:32:
- icomment: "See branch [bug-b343fe8656] for a proposed fix."
- login: "griffin"
- mimetype: "text/x-markdown"
Ticket change [e570077f2f] (rid 235558) by apnadkarni on 2024-11-29 00:03:53:
- icomment:
I *think* that branch mostly describes what the caller needs to do except for one case. 1. `Tcl_ListObjIndex` may return a `Tcl_Obj` with (a) an internal reference held (non-0 ref count) or (b) a 0 ref count. 2. The caller may either (a) hold on to the object, (b) simply access the content and dispose of it, or (c) pass it to another function. The case not described that needs more clarity is 1(b) with 2(c). In that case, I don't think `Tcl_BounceRefCount` is always safe. In particular if the second function that is called is a "hairy monster" like `Tcl_ObjSetVar2`, the correct sequence is wrapping that call between a IncrRefCount and DecrRefCount and not Bounce. But explaining that succinctly is another matter. A related note - there is also a REFERENCE COUNT MANAGEMENT section in that page. My suggestion is to merge into the trunk but leave this ticket open as a reminder to clarify the abovementioned case.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [981e54f9b9] (rid 235642) by dkf on 2024-12-02 09:43:35:
- icomment:
The hairiest hair on the monster happens when the called function decrements the reference count of the object back to zero. This definitely happens in `Tcl_EvalObj()` in some cases, but for `Tcl_ObjSetVar2()` is only ever likely to be a factor for the keyObj and valueObj arguments if there are traces in play (as those could effectively reject or replace the write). ## Background For ***untraced*** variables, the reference count changes are: * `nameObj`: don't increment reference count * `keyObj`: increment reference count _only_ when new array element is allocated * `valueObj`: increment reference count _only_ on successful write **Constants** reject writes prior to reference counts being updated, and don't apply to arrays or their elements (because there was a case in there that made my head ache and it was easier to just block safely and let someone else enable when they figure out what a constant array means and how you'd actually make it). This sort of thing is why I made constants a separate thing, despite it being possible to simulate them with traces/links in older versions of Tcl. **Traces** typically involve callbacks into the Tcl interpreter with no restrictions, and happen after the write has been done, so reference count updates can go down in that case (e.g., because a whole array trace removes the element you've just made) and full hairiness is achieved; both the key and the value arguments have their reference counts decreased back to their start value before the call to `Tcl_ObjSetVar2` exits (i.e., the handles are not safe to use after exit at all).
- login: "dkf"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [9ebbf9bf0e] (rid 235887) by apnadkarni on 2024-12-10 10:09:12:
- closedate changed to: "2460654.92305748"
- closer changed to: "apnadkarni"
- login: "apnadkarni"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"