Index: generic/nsf.c =================================================================== diff -u -r49900e2a66b1bd8cb5ff9ec6f16d9cb80ce28656 -re20e1c1aa5e3b8f1020a455605d6f971ab622f5b --- generic/nsf.c (.../nsf.c) (revision 49900e2a66b1bd8cb5ff9ec6f16d9cb80ce28656) +++ generic/nsf.c (.../nsf.c) (revision e20e1c1aa5e3b8f1020a455605d6f971ab622f5b) @@ -25160,6 +25160,9 @@ NsfFinalizeCmd(Tcl_Interp *interp, int withKeepvars) { int result; + /* fprintf(stderr, "#### (%lx) NsfFinalizeCmd exitHandlerRound %d\n", + (long)(void*)pthread_self(),RUNTIME_STATE(interp)->exitHandlerDestroyRound );*/ + nonnull_assert(interp != NULL); #if defined(NSF_PROFILE) @@ -31686,12 +31689,14 @@ static void ExitHandler(ClientData clientData) { Tcl_Interp *interp = (Tcl_Interp *)clientData; - int i, flags; + int flags; NsfRuntimeState *rst = RUNTIME_STATE(interp); nonnull_assert(clientData != NULL); - /*fprintf(stderr, "+++ ExitHandler interp %p deleted %d\n", interp, (Tcl_Interp_flags(interp) & DELETED));*/ + /*fprintf(stderr, "+++ (%lx) ExitHandler interp %p deleted %d exitHandlerDestroyRound %d\n", + (long)(void*)pthread_self(), interp, (Tcl_Interp_flags(interp) & DELETED), + rst->exitHandlerDestroyRound);*/ /* * Don't use exit handler, if the interpreter is already destroyed. @@ -31721,7 +31726,6 @@ CallStackPopAll(interp); - if (rst->exitHandlerDestroyRound == NSF_EXITHANDLER_OFF) { NsfFinalizeCmd(interp, 0); } @@ -31732,9 +31736,12 @@ MEM_COUNT_FREE("Tcl_InitHashTable", &rst->activeFilterTablePtr); Tcl_DeleteHashTable(&rst->activeFilterTablePtr); - /* free global objects */ - for (i = 0; i < nr_elements(NsfGlobalStrings); i++) { - DECR_REF_COUNT(NsfGlobalObjs[i]); + /* free "global" (per main interp) objects */ + { + int i; + for (i = 0; i < nr_elements(NsfGlobalStrings); i++) { + DECR_REF_COUNT(NsfGlobalObjs[i]); + } } NsfStringIncrFree(&rst->iss); @@ -31810,7 +31817,7 @@ nonnull_assert(clientData != NULL); - /* fprintf(stderr, "+++ Nsf_ThreadExitProc %p\n", clientData);*/ + /*fprintf(stderr, "+++ (%lx) Nsf_ThreadExitProc %p\n", (long)(void*)pthread_self(), clientData);*/ Tcl_DeleteThreadExitHandler(Nsf_ThreadExitProc, clientData); Tcl_DeleteExitHandler(Nsf_ExitProc, clientData); @@ -31828,15 +31835,14 @@ nonnull_assert(clientData != NULL); - /*fprintf(stderr, "+++ Nsf_ExitProc %p\n", clientData);*/ + /*fprintf(stderr, "+++ (%lx) Nsf_ExitProc %p\n", (long)(void*)pthread_self(), clientData);*/ #if defined(TCL_THREADS) Tcl_DeleteExitHandler(Nsf_ExitProc, clientData); Tcl_DeleteThreadExitHandler(Nsf_ThreadExitProc, clientData); #endif ExitHandler(clientData); } - /* * Registers thread/application exit handlers. */