Skip to content
Tcl Source Code History Of Ticket 218075
Login

History Of Ticket 218075

Artifacts Associated With Ticket 218075

  1. Ticket change [734736b718] (rid 105021) by nobody on 2000-10-26 00:52:54:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 1630 Bug
      Version: 8.1b1
      SubmitDate: '1999-03-25'
      LastModified: '1999-11-30'
      Severity: MED
      Status: Closed
      Submitter: pat
      ChangedBy: hobbs
      OS: Other
      OSVersion: BSD/OS 4.0.1
      Machine: NA
      FixedDate: '2000-10-25'
      ClosedDate: '1999-11-30'
      
      
      Name:
      Robert Hare
      
      ReproducibleScript:
          Delete procedures registered using Tcl_SetAssocData are not called
          during a
          Tcl_Exit. It seems like calling Tcl_Exit would delete
          each interpreter and call all registered delete procedures and then exit
          the process.  Is there a reason it is not done this way?  It seems like
          this might
          get rid of having to register so many exit handlers.
          
          This is basically just an architectual question. --- Thanks
      
      
      
      
      
      Note, this is part RFE, part bug.  The problem is when there are shared resources between a Tcl shell and another process.  If the resource is not explicitly freed on exit, it will appear to the other process that the shell is still reserving the resource.  
      
      The concern is that finalization will be really slow if we explicitly call each free proc.  Maybe we need to have the ability to specify how to exit, or maybe the speed concerns turn out to be irrelevant.  either way we need to look into a solution.
      
      I emailed Robert again trying to clear the matter up. Here was his response:
      
      I understand that it is called during a Tcl_DeleteInterp.  My question is
      why doesn't Tcl_Exit do all the same things?  It seems strange to treat
      exiting an application differently than just deleting all interpreters and
      then exiting.
      
      The way it is done now assumes that the only reason you would want the
      routines registered with the interpreter to run on exit is to clear up
      memory. What about other resources allocated by extensions? 
      
      Here is an example:
      
      I have a extension for a database.  During the course of using the
      extension connections to the database are created.  These are done using a
      shared memory segment.  If the application exits or the interpreter is
      deleted all resources allocated (including shared memory) need to be
      freed.  Simply exiting the application can leave shared memory segments
      still in use and really mess up other processes using them.  
      
      Why choose to handle an application exit in a special way?  The more I
      think about it, the more this seems like a bug. :-)
      
      04/07/1999 11:33 - surles -
      
      --
      All in all, the user should match Tcl_CreateInterp with Tcl_DeleteInterp
      if they want AssocData handlers to be called.  Otherwise, the better
      way to handle this is to use Tcl_CreateExitHandler and
      Tcl_DeleteExitHandler to make sure cleanup is done truly on exit. 
      -- 11/30/1999 hobbs
      
      
      
    4. foundin initialized to: "obsolete: 8.1b1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to:
      Interpreter Associated data delete proc not called when tcls
      
    11. type initialized to: "RFE"
  2. Ticket change [ca9317edd8] (rid 95375) by welch on 2000-10-26 08:13:46:

    1. closedate changed to: "2000-10-26T01:13:46"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [d4186ad8e3] (rid 123390) by dgp on 2001-04-17 04:40:07:

    1. foundin changed to: "None"
    2. status changed to: "Open"
    3. subsystem changed to: "None"
  4. Ticket change [80886d0fca] (rid 116888) by dgp on 2001-04-17 04:41:56:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      See also FR 227269
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. subsystem changed to: "45. Parsing and Eval"
    5. username: "dgp"
  5. Ticket change [4640031eee] (rid 99490) by dgp on 2003-11-13 06:15:43:

    1. assignee changed to: "dgp"
  6. Ticket change [4b601f5cd2] (rid 126701) by dgp on 2006-06-10 02:48:37:

    1. closedate changed to: "2006-06-09T19:48:37"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      
      
      I made an attempt to create a patch
      that implements this feature request
      and discovered why it won't mesh with
      Tcl's design.
      
      The logic that controls the destruction
      of a Tcl_Interp is to defer the teardown
      of the interp (including all the callbacks
      that clean up assocdata and that tend to
      command deletion issues), until all 
      "active evals" in the interp have fully
      unwound.
      
      Probably the most frequent way Tcl_Exit()
      gets called is via the evaluation of
      the [exit] command.  When [exit] is getting
      evaluated, the interp is busy, so none
      of its cleanup is going to be done anyway.
      
      This means the only way to be sure an
      important bit of cleanup of assocdata
      (subject of this report) gets done is
      to use both the "delProc" argument to
      Tcl_SetAssocData() to handle cleanup
      in the case that an interp gets deleted
      before process finalization, and also
      to use Tcl_Create(Thread)ExitHandler()
      to register a cleanup callback to
      handle cleanup during process finalization.
      
      The two cleanup routes need to be aware of
      each other as well so they don't both fire,
      or if they do both fire, they can handle
      any possible state.
      
      Note that some types of cleanup that are
      important in the interp deletion case
      (like memory free-ing to avoid memory leaks)
      need not be handled at process finalization
      time, when the OS will do the relevant cleanup
      anyway.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Rejected"
    7. status changed to: "Closed"
    8. username: "dgp"