From 598a2d7dd6d3830c59de31a4b4af8ccf1991fdc4 Mon Sep 17 00:00:00 2001 From: mig Date: Sun, 8 May 2011 13:00:24 +0000 Subject: is this a proper fix? Or is it invalidating too much? --- generic/tclInt.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tclInt.h b/generic/tclInt.h index f2fd0b8..d196d96 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3757,6 +3757,9 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, CONST char *file, #define TclInvalidateNsCmdLookup(nsPtr) \ if ((nsPtr)->numExportPatterns) { \ (nsPtr)->exportLookupEpoch++; \ + } \ + if ((nsPtr)->commandPathLength) { \ + (nsPtr)->cmdRefEpoch++; \ } /* -- cgit v0.12 From ab1ff5f9d6a78c586f81d6c274544cb5b4c45b92 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 1 Jun 2011 12:06:54 +0000 Subject: fix for [Bug 3309871]: Valgrind finds: invalid read in TclMaxListLength() --- ChangeLog | 5 +++++ generic/tclUtil.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fe71c5..78c78c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-06-01 Jan Nijtmans + + * generic/tclUtil.c: fix for [Bug 3309871]: Valgrind finds: + invalid read in TclMaxListLength() + 2011-05-25 Don Porter * library/msgcat/msgcat.tcl: Backport improvements to msgcat diff --git a/generic/tclUtil.c b/generic/tclUtil.c index b00489d..9a23291 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -409,8 +409,8 @@ TclMaxListLength( do { bytes++; numBytes -= (numBytes != -1); - } while (numBytes && TclIsSpaceProc(*bytes)); - if (numBytes == 0) { + } while (numBytes && (*bytes != '\0') && TclIsSpaceProc(*bytes)); + if ((numBytes == 0) || (*bytes == '\0')) { break; } /* (*bytes) is non-space; return to counting state */ -- cgit v0.12 From c31b5e030892e09c7f5bdc8538ecc09b760bab3b Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 1 Jun 2011 13:14:20 +0000 Subject: Revised fix for bug 3309871 --- generic/tclUtil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 9a23291..f5c2926 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -409,8 +409,8 @@ TclMaxListLength( do { bytes++; numBytes -= (numBytes != -1); - } while (numBytes && (*bytes != '\0') && TclIsSpaceProc(*bytes)); - if ((numBytes == 0) || (*bytes == '\0')) { + } while (numBytes && TclIsSpaceProc(*bytes)); + if ((numBytes == 0) || ((numBytes == -1) && (*bytes == '\0'))) { break; } /* (*bytes) is non-space; return to counting state */ -- cgit v0.12 From 2b5168b50a2657829ffc6687f1f13f87acb053ce Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 2 Jun 2011 16:55:02 +0000 Subject: Remove TclCleanupLiteralTable (see 994838). --- ChangeLog | 6 +++++ generic/tclBasic.c | 1 - generic/tclInt.h | 2 -- generic/tclLiteral.c | 71 ---------------------------------------------------- 4 files changed, 6 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2493519..4eccf76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-06-02 Don Porter + + * generic/tclBasic.c: Removed TclCleanupLiteralTable(), and old + * generic/tclInt.h: band-aid routine put in place while a fix + * generic/tclLiteral.c: for [Bug 994838] took shape. No longer needed. + 2011-06-02 Donal K. Fellows * generic/tclInt.h (TclInvalidateNsCmdLookup): [Bug 3185407]: Extend diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 750c9e2..eb041c6 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -1257,7 +1257,6 @@ DeleteInterpProc( * table, as it will be freed later in this function without further use. */ - TclCleanupLiteralTable(interp, &(iPtr->literalTable)); TclHandleFree(iPtr->handle); TclTeardownNamespace(iPtr->globalNsPtr); diff --git a/generic/tclInt.h b/generic/tclInt.h index d9b82d5..679277a 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2564,8 +2564,6 @@ MODULE_SCOPE double TclCeil(mp_int *a); MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp, const char *value); MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp, Tcl_Channel chan); -MODULE_SCOPE void TclCleanupLiteralTable(Tcl_Interp *interp, - LiteralTable *tablePtr); MODULE_SCOPE ContLineLoc* TclContinuationsEnter(Tcl_Obj *objPtr, int num, int *loc); MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr, diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 62dc5c0..2c91b82 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -75,77 +75,6 @@ TclInitLiteralTable( /* *---------------------------------------------------------------------- * - * TclCleanupLiteralTable -- - * - * This function frees the internal representation of every literal in a - * literal table. It is called prior to deleting an interp, so that - * variable refs will be cleaned up properly. - * - * Results: - * None. - * - * Side effects: - * Each literal in the table has its internal representation freed. - * - *---------------------------------------------------------------------- - */ - -void -TclCleanupLiteralTable( - Tcl_Interp *interp, /* Interpreter containing literals to purge */ - LiteralTable *tablePtr) /* Points to the literal table being - * cleaned. */ -{ - int i; - LiteralEntry* entryPtr; /* Pointer to the current entry in the hash - * table of literals. */ - LiteralEntry* nextPtr; /* Pointer to the next entry in the bucket. */ - Tcl_Obj* objPtr; /* Pointer to a literal object whose internal - * rep is being freed. */ - const Tcl_ObjType* typePtr; /* Pointer to the object's type. */ - int didOne; /* Flag for whether we've removed a literal in - * the current bucket. */ - -#ifdef TCL_COMPILE_DEBUG - TclVerifyGlobalLiteralTable((Interp *) interp); -#endif /* TCL_COMPILE_DEBUG */ - - for (i=0 ; inumBuckets ; i++) { - /* - * It is tempting simply to walk each hash bucket once and delete the - * internal representations of each literal in turn. It's also wrong. - * The problem is that freeing a literal's internal representation can - * delete other literals to which it refers, making nextPtr invalid. - * So each time we free an internal rep, we start its bucket over - * again. - */ - - do { - didOne = 0; - entryPtr = tablePtr->buckets[i]; - while (entryPtr != NULL) { - objPtr = entryPtr->objPtr; - nextPtr = entryPtr->nextPtr; - typePtr = objPtr->typePtr; - if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { - if (objPtr->bytes == NULL) { - Tcl_Panic( "literal without a string rep" ); - } - objPtr->typePtr = NULL; - typePtr->freeIntRepProc(objPtr); - didOne = 1; - break; - } else { - entryPtr = nextPtr; - } - } - } while (didOne); - } -} - -/* - *---------------------------------------------------------------------- - * * TclDeleteLiteralTable -- * * This function frees up everything associated with a literal table -- cgit v0.12