Index: generic/tclCompExpr.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompExpr.c,v
retrieving revision 1.27
diff -u -r1.27 tclCompExpr.c
--- generic/tclCompExpr.c	17 Jul 2005 21:17:40 -0000	1.27
+++ generic/tclCompExpr.c	3 Aug 2005 21:49:19 -0000
@@ -288,8 +288,7 @@
  * 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.
Index: generic/tclEvent.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclEvent.c,v
retrieving revision 1.60
diff -u -r1.60 tclEvent.c
--- generic/tclEvent.c	17 Jul 2005 21:17:40 -0000	1.60
+++ generic/tclEvent.c	3 Aug 2005 21:49:19 -0000
@@ -874,7 +874,8 @@
 	 * done after the exit handlers, because there are order dependencies.
 	 */
 
-	TclFinalizeCompExecEnv();
+	TclFinalizeCompilation();
+	TclFinalizeExecution();
 	TclFinalizeEnvironment();
 
 	/* 
@@ -884,6 +885,18 @@
 
 	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 @@
 	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_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;
     }
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.242
diff -u -r1.242 tclInt.h
--- generic/tclInt.h	21 Jul 2005 21:49:08 -0000	1.242
+++ generic/tclInt.h	3 Aug 2005 21:49:19 -0000
@@ -1960,7 +1960,6 @@
 			    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	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));
Index: generic/tclObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclObj.c,v
retrieving revision 1.88
diff -u -r1.88 tclObj.c
--- generic/tclObj.c	17 Jul 2005 21:17:44 -0000	1.88
+++ generic/tclObj.c	3 Aug 2005 21:49:20 -0000
@@ -17,7 +17,6 @@
 
 #include "tclInt.h"
 #include "tommath.h"
-#include "tclCompile.h"
 #include <float.h>
 
 /*
@@ -405,23 +404,22 @@
 /*
  *----------------------------------------------------------------------
  *
- * 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 @@
 	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();
 }
 
 /*
