Artifacts Associated With Ticket 7368d225a657380c
Ticket change [e68e1974c2] (rid 138615) by dgp on 2014-07-10 14:40:59:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Tcl_SetVar2() creates the (Tcl_Obj) value out of the (const char *) data it receives, then passes it on to Tcl_SetVar2Ex() to manage the rest of its lifetime. This mostly works, so long as Tcl_SetVar2Ex() stores the value in a variable. When flags includes TCL_APPEND_VALUE and does not include TCL_LIST_ELEMENT that does not happen and the mem leaks. There may be other leak scenarios too. The testing package pkgua exposes this, when examined with valgrind.
- foundin initialized to: "8.5"
- is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "07. Variables"
- title initialized to: "Tcl_SetVar2() leaks memory"
- type initialized to: "Bug"
Ticket change [777e85d01c] (rid 138616) by dgp on 2014-07-10 14:59:24:
- icomment:
Another likely leak scenario is a variable name that cannot be created.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [e0887feb41] (rid 138617) by dgp on 2014-07-10 15:04:19:
- icomment: "Um, no. The latter case is handled."
- login: "dgp"
- mimetype: "text/plain"
Ticket change [ed4250409b] (rid 138620) by dgp on 2014-07-10 15:55:34:
- icomment:
This is a gap in the fix for bug 1334947. http://core.tcl.tk/tcl/info/1334947 For all the same reasons that was fixed in a mildly incompatible way, this should also be treated the same, with the Tcl_*SetVar* machinery taking care of all zero-refcount value housekeeping to relieve all callers of that burden. Those harmed will be anyone with code like this: Tcl_Obj *value = Tcl_New...(); Tcl_SetVar2Ex(interp, "foo", NULL, value, TCL_APPEND_VALUE); Tcl_DecrRefCount(value); Anyone with such code likely has the Tcl_DecrRefCount() call in place only because they added it to plug the memleak that would otherwise be observed. With this change to the core, that code will have to modified to continue working and avoid a segfault (same as we did with the other 1334947 changes). If the code must continue running with older Tcl releases, then the fix is to add a Tcl_IncrRefCount(value); call prior to SetVar so that refcount management is balanced. Any such code with the luxury of ditching all old Tcl releases and claiming support of solely 8.5.16+ and 8.6.2+ can just drop the Tcl_DecrRefCount() call altogether and take advantage of the improved interface standard. I expect to count the number of impacted users on one hand. TCL_APPEND_VALUE is just not a popular flag option here in my experience.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [b3d220aae6] (rid 138624) by dgp on 2014-07-10 16:41:32:
- assignee changed to: "dgp"
- closedate changed to: "2456849.19551197"
- closer changed to: "dgp"
- icomment: "Fixed for 8.5.16 and 8.6.2"
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- severity changed to: "Important"
- status changed to: "Closed"