Skip to content
Tcl Source Code History Of Ticket 1ae12987cb21ae25
Login

History Of Ticket 1ae12987cb21ae25

Artifacts Associated With Ticket 1ae12987cb21ae25

  1. Ticket change [0a165629c8] (rid 149281) by mr_calvin on 2016-10-21 14:37:03:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. 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.
      
    5. foundin initialized to: "core-8-6-branch"
    6. is_private initialized to: "0"
    7. login: "mr_calvin"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "d4d1d8192a46acf2c7d58cddc1040ecdbc9c9d77"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "mr_calvin"
    14. subsystem initialized to: "19. [history]"
    15. title initialized to:
      Clean up history (::tcl::history) before/on exit (i.e., before exit handlers)
      
    16. type initialized to: "Bug"
  2. Ticket change [514c9ee9b5] (rid 149354) by dkf on 2016-10-30 08:30:31:

    1. assignee changed to: "dkf"
    2. closedate changed to: "2457691.85453347"
    3. closer changed to: "dkf"
    4. 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.
      
    5. login: "dkf"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"