Artifacts Associated With Ticket 1ae12987cb
Ticket change [0a165629c8] (rid 149281) by mr_calvin on 2016-10-21 14:37:03:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The internal event storage of ::history (::tcl::history array) is not explicitly cleared when exiting (master interp, Tcl_Exit). Extensions' exit handlers, therefore, potentially see unbalanced refcounts on Tcl_Objs referenced from ::tcl::history. See for an example http://paste.tclers.tk/3973. Possible action items: - call [::history::clear] on Tcl_Exit (not only for interp teardown). - have [rename ::history {}] run the cleanup. Excerpt from the IRC discussion with dgp and dkf (): mr_calvin: (my main question basically is: why is an interactive tclsh not cleaning up the ::tcl::history at some early point during exit, before the exit handlers kick in.) <dgp> IIRC, [history] is coded mostly (entirely?) in Tcl? <dgp> And Tcl lacks good interface to exit handling. mr_calvin: yeah … library/history.tcl <dkf> Could just make Tcl_Main call [history clear] on the way out? <dgp> no <dkf> as handling all cases *very* hard <dgp> this cleanup would normally be handled by interp teardown <dgp> ....that [exit] does not tear down interps. <dkf> if you have something that needs to be freed, you need an exit handler and those REQUIRE the C API to set up dkf: as I wrote a little earlier. we do internal bookkeeping on Tcl_Objs intreps in NSF/NX, on exit, we draw the balance (exit handler) and references from tcl::history show up as unbalanced refcounts. <dkf> but effectively we *know* there are references retained unless you finalize mr_calvin: but doing a “unset -nocomplain ::tcl::history” in our exit handler would be one option (at least in our memdebug build) to balance those refcounts in time, wouldn’t it? <dkf> [::history clear] would leave me happier <dgp> Does [rename history {}] do a cleanup? <dkf> probably not <dgp> that would be a bug worth fixing. - foundin initialized to: "core-8-6-branch"
- is_private initialized to: "0"
- login: "mr_calvin"
- priority initialized to: "5 Medium"
- private_contact initialized to: "d4d1d8192a46acf2c7d58cddc1040ecdbc9c9d77"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "mr_calvin"
- subsystem initialized to: "19. [history]"
- title initialized to:
Clean up history (::tcl::history) before/on exit (i.e., before exit handlers)
- type initialized to: "Bug"
Ticket change [514c9ee9b5] (rid 149354) by dkf on 2016-10-30 08:30:31:
- assignee changed to: "dkf"
- closedate changed to: "2457691.85453347"
- closer changed to: "dkf"
- icomment:
Adding a trace seems to do the deletion correctly; plain <code>rename history {}</code> now drops the references to objects in its storage and removes the rest of the history implementation as well. I can't guarantee that it will all clean up perfectly on <tt>exit</tt>, but Tcl doesn't make strong guarantees in that case anyway. You have to finalize the library to get that guarantee and that's not on the normal exit path. - login: "dkf"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"