|
2006-06-10
| ||
| 02:48 | • Closed ticket [218075ffff]: Interpreter Associated data delete proc not called w... artifact: 4b601f5cd2 user: dgp | |
|
2003-11-13
| ||
| 06:15 | • Ticket [218075ffff]: 1 change artifact: 4640031eee user: dgp | |
|
2001-04-17
| ||
| 04:41 | • Ticket [218075ffff]: 5 changes artifact: 80886d0fca user: dgp | |
| 04:40 | • Open ticket [218075ffff]. artifact: d4186ad8e3 user: dgp | |
|
2000-10-26
| ||
| 08:13 | • Closed ticket [218075ffff]. artifact: ca9317edd8 user: welch | |
| 00:52 | • New ticket [218075ffff]. artifact: 734736b718 user: nobody | |
Interpreter Associated data delete proc not called when tcls
Closed / Rejected218075ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 20 years ago
Descriptionplain2000-10-26 00:52:54
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
welch Closed ticket [218075ffff].
[History diff]2000-10-26 08:13:46
dgp Open ticket [218075ffff].
[History diff]2001-04-17 04:40:07
dgpplain2001-04-17 04:41:56
Logged In: YES user_id=80530 See also FR 227269
dgp Ticket [218075ffff]: 1 change
[History diff]2003-11-13 06:15:43
dgpplain2006-06-10 02:48:37
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.
Log in (anonymous is fine) to add a comment.