From eb0feb979757670c7509380a53ba1af03cb44666 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 3 Aug 2005 22:25:11 +0000 Subject: * generic/tclCompExpr.c: Untangled some dependencies in the * generic/tclEvent.c: order of finalization routines. * generic/tclInt.h: [Bug 1251399] * generic/tclObj.c: --- ChangeLog | 7 +++++++ generic/tclCompExpr.c | 5 ++--- generic/tclEvent.c | 37 ++++++++++++++++++++++++++----------- generic/tclInt.h | 4 ++-- generic/tclObj.c | 23 ++++++++++++----------- 5 files changed, 49 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d3c975..ffbadcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-08-03 Don Porter + + * generic/tclCompExpr.c: Untangled some dependencies in the + * generic/tclEvent.c: order of finalization routines. + * generic/tclInt.h: [Bug 1251399] + * generic/tclObj.c: + 2005-07-30 Daniel Steffen * unix/tclLoadDyld.c (TclpDlopen, TclpLoadMemory): workarounds diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 9ca9f73..e102d28 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompExpr.c,v 1.27 2005/07/17 21:17:40 dkf Exp $ + * RCS: @(#) $Id: tclCompExpr.c,v 1.28 2005/08/03 22:25:11 dgp Exp $ */ #include "tclInt.h" @@ -288,8 +288,7 @@ TclCompileExpr(interp, script, numBytes, envPtr) * TclFinalizeCompilation -- * * Clean up the compilation environment so it can later be properly - * reinitialized. This procedure is called by TclFinalizeCompExecEnv() in - * tclObj.c, which in turn is called by Tcl_Finalize(). + * reinitialized. This procedure is called by Tcl_Finalize(). * * Results: * None. diff --git a/generic/tclEvent.c b/generic/tclEvent.c index e70ce67..66c8f85 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEvent.c,v 1.60 2005/07/17 21:17:40 dkf Exp $ + * RCS: @(#) $Id: tclEvent.c,v 1.61 2005/08/03 22:25:11 dgp Exp $ */ #include "tclInt.h" @@ -874,7 +874,8 @@ Tcl_Finalize() * done after the exit handlers, because there are order dependencies. */ - TclFinalizeCompExecEnv(); + TclFinalizeCompilation(); + TclFinalizeExecution(); TclFinalizeEnvironment(); /* @@ -884,6 +885,18 @@ Tcl_Finalize() TclFinalizeFilesystem(); + /* + * Undo all Tcl_ObjType registrations, and reset the master list + * of free Tcl_Obj's. After this returns, no more Tcl_Obj's should + * be allocated or freed. + * + * Note in particular that TclFinalizeObjects() must follow + * TclFinalizeFilesystem() because TclFinalizeFilesystem free's + * the Tcl_Obj that holds the path of the current working directory. + */ + + TclFinalizeObjects(); + /* * We must be sure the encoding finalization doesn't need to examine * the filesystem in any way. Since it only needs to clean up @@ -909,13 +922,6 @@ Tcl_Finalize() TclFinalizeThreadData(); /* - * Free synchronization objects. There really should only be one - * thread alive at this moment. - */ - - TclFinalizeSynchronization(); - - /* * We defer unloading of packages until very late to avoid memory * access issues. Both exit callbacks and synchronization variables * may be stored in packages. @@ -952,14 +958,23 @@ Tcl_Finalize() Tcl_Panic("exit handlers were created during Tcl_Finalize"); } + TclFinalizePreserve(); + /* - * There shouldn't be any malloc'ed memory after this. + * Free synchronization objects. There really should only be one + * thread alive at this moment. */ - TclFinalizePreserve(); + TclFinalizeSynchronization(); + #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) TclFinalizeThreadAlloc(); #endif + + /* + * At this point, there should no longer be any ckalloc'ed memory. + */ + TclFinalizeMemorySubsystem(); inFinalize = 0; } diff --git a/generic/tclInt.h b/generic/tclInt.h index 28538f3..bc7c0d8 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.242 2005/07/21 21:49:08 dkf Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.243 2005/08/03 22:25:11 dgp Exp $ */ #ifndef _TCLINT @@ -1960,7 +1960,6 @@ MODULE_SCOPE int TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])) ; MODULE_SCOPE void TclFinalizeAllocSubsystem _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeAsync _ANSI_ARGS_((void)); -MODULE_SCOPE void TclFinalizeCompExecEnv _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeCompilation _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeDoubleConversion _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeEncodingSubsystem _ANSI_ARGS_((void)); @@ -1973,6 +1972,7 @@ MODULE_SCOPE void TclFinalizeLoad _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeLock _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeMemorySubsystem _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeNotifier _ANSI_ARGS_((void)); +MODULE_SCOPE void TclFinalizeObjects _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizePreserve _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeSynchronization _ANSI_ARGS_((void)); MODULE_SCOPE void TclFinalizeThreadData _ANSI_ARGS_((void)); diff --git a/generic/tclObj.c b/generic/tclObj.c index 3271811..8a58b7c 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -12,12 +12,11 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclObj.c,v 1.88 2005/07/17 21:17:44 dkf Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.89 2005/08/03 22:25:11 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" -#include "tclCompile.h" #include /* @@ -405,23 +404,22 @@ TclInitObjSubsystem() /* *---------------------------------------------------------------------- * - * TclFinalizeCompExecEnv -- + * TclFinalizeObjects -- * - * This procedure is called by Tcl_Finalize to clean up the Tcl - * compilation and execution environment so it can later be properly - * reinitialized. + * This procedure is called by Tcl_Finalize to clean up all + * registered Tcl_ObjType's and to reset the tclFreeObjList. * * Results: * None. * * Side effects: - * Cleans up the compilation and execution environment + * None. * *---------------------------------------------------------------------- */ void -TclFinalizeCompExecEnv() +TclFinalizeObjects() { Tcl_MutexLock(&tableMutex); if (typeTableInitialized) { @@ -429,12 +427,15 @@ TclFinalizeCompExecEnv() typeTableInitialized = 0; } Tcl_MutexUnlock(&tableMutex); + + /* + * All we do here is reset the head pointer of the linked list of + * free Tcl_Obj's to NULL; the memory finalization will take care + * of releasing memory for us. + */ Tcl_MutexLock(&tclObjMutex); tclFreeObjList = NULL; Tcl_MutexUnlock(&tclObjMutex); - - TclFinalizeCompilation(); - TclFinalizeExecution(); } /* -- cgit v0.12