diff options
| author | andreask <andreask> | 2015-05-27 18:25:38 (GMT) |
|---|---|---|
| committer | andreask <andreask> | 2015-05-27 18:25:38 (GMT) |
| commit | 1e5a39f2b22f3575e8970fcc369d59c8ee21bd10 (patch) | |
| tree | 36b76533e102724d72049664813d8ea4459b781f /generic/tclObj.c | |
| parent | 130dd7e739721ee20c20a7a1a61c49deb888f39f (diff) | |
| parent | 63505f5709a34ce8abc07c15b4ca1c616bb5c90f (diff) | |
| download | tcl-1e5a39f2b22f3575e8970fcc369d59c8ee21bd10.zip tcl-1e5a39f2b22f3575e8970fcc369d59c8ee21bd10.tar.gz tcl-1e5a39f2b22f3575e8970fcc369d59c8ee21bd10.tar.bz2 | |
Make tweak to the mem-debug tracking official. It is now again possible to use regular packages with a mem-debug core without inciting a panic.
Diffstat (limited to 'generic/tclObj.c')
| -rw-r--r-- | generic/tclObj.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index fb09a9e..d278b1f 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -1322,6 +1322,39 @@ TclFreeObj( ObjInitDeletionContext(context); +# ifdef TCL_THREADS + /* + * Check to make sure that the Tcl_Obj was allocated by the current + * thread. Don't do this check when shutting down since thread local + * storage can be finalized before the last Tcl_Obj is freed. + */ + + if (!TclInExit()) { + Tcl_HashTable *tablePtr; + Tcl_HashEntry *hPtr; + ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + + tablePtr = tsdPtr->objThreadMap; + if (!tablePtr) { + Tcl_Panic("TclFreeObj: object table not initialized"); + } + hPtr = Tcl_FindHashEntry(tablePtr, (char *) objPtr); + if (hPtr) { + /* + * As the Tcl_Obj is going to be deleted we remove the entry. + */ + + ObjData *objData = Tcl_GetHashValue(hPtr); + + if (objData != NULL) { + ckfree((char *) objData); + } + + Tcl_DeleteHashEntry(hPtr); + } + } +# endif + /* * Check for a double free of the same value. This is slightly tricky * because it is customary to free a Tcl_Obj when its refcount falls @@ -3717,20 +3750,6 @@ Tcl_DbDecrRefCount( "Trying to decr ref count of " "Tcl_Obj allocated in another thread"); } - - /* - * If the Tcl_Obj is going to be deleted, remove the entry. - */ - - if ((objPtr->refCount - 1) <= 0) { - ObjData *objData = Tcl_GetHashValue(hPtr); - - if (objData != NULL) { - ckfree((char *) objData); - } - - Tcl_DeleteHashEntry(hPtr); - } } # endif #endif |
