Artifacts Associated With Ticket 218075ffffffffff
Ticket change [734736b718] (rid 105021) by nobody on 2000-10-26 00:52:54:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- 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 - foundin initialized to: "obsolete: 8.1b1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to:
Interpreter Associated data delete proc not called when tcls
- type initialized to: "RFE"
Ticket change [ca9317edd8] (rid 95375) by welch on 2000-10-26 08:13:46:
- closedate changed to: "2000-10-26T01:13:46"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [d4186ad8e3] (rid 123390) by dgp on 2001-04-17 04:40:07:
- foundin changed to: "None"
- status changed to: "Open"
- subsystem changed to: "None"
Ticket change [80886d0fca] (rid 116888) by dgp on 2001-04-17 04:41:56:
- icomment:
Logged In: YES user_id=80530 See also FR 227269
- login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "45. Parsing and Eval"
- username: "dgp"
- icomment:
Ticket change [4640031eee] (rid 99490) by dgp on 2003-11-13 06:15:43:
- assignee changed to: "dgp"
Ticket change [4b601f5cd2] (rid 126701) by dgp on 2006-06-10 02:48:37:
- closedate changed to: "2006-06-09T19:48:37"
- closer changed to: "dgp"
- 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.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Rejected"
- status changed to: "Closed"
- username: "dgp"