diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2004-07-15 17:42:11 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2004-07-15 17:42:11 (GMT) |
commit | 904a467ccfeca1913883354a57a3639c84f403b1 (patch) | |
tree | c90cbe8bfbba40582d7d52caa3d333c26062927d /generic | |
parent | 4d636106758757629d87a6b8e9fa35cb684fbe93 (diff) | |
download | tcl-904a467ccfeca1913883354a57a3639c84f403b1.zip tcl-904a467ccfeca1913883354a57a3639c84f403b1.tar.gz tcl-904a467ccfeca1913883354a57a3639c84f403b1.tar.bz2 |
* generic/tclCompile.c (TclCompileScript):
* generic/tclLiteral.c (TclReleaseLiteral): fix for [Bug 467523],
which resurfaced with the latest changes. The previous strategy
was to have special code in TclReleaseLiteral to handle the
self-references generated by empty scripts. The new approach
avoids the self-reference altogether, by having empty scripts
return an unshared literal.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCompile.c | 11 | ||||
-rw-r--r-- | generic/tclLiteral.c | 18 |
2 files changed, 9 insertions, 20 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 5376123..03b62ca 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompile.c,v 1.70 2004/07/08 18:46:05 msofer Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.71 2004/07/15 17:42:12 msofer Exp $ */ #include "tclInt.h" @@ -1208,11 +1208,16 @@ TclCompileScript(interp, script, numBytes, envPtr) /* * If the source script yielded no instructions (e.g., if it was empty), * push an empty string as the command's result. + * + * WARNING: push an unshared object! If the script being compiled is a + * shared empty string, it will otherwise be self-referential and cause + * difficulties with literal management [Bugs 467523, 983660]. We used to + * have special code in TclReleaseLiteral to handle this particular + * self-reference, but now opt for avoiding its creation altogether. */ if (envPtr->codeNext == entryCodeNext) { - TclEmitPush(TclRegisterLiteral(envPtr, "", 0, /*onHeap*/ 0), - envPtr); + TclEmitPush(TclAddLiteralObj(envPtr, Tcl_NewObj(), NULL), envPtr); } envPtr->numSrcBytes = (p - script); diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 19042fd..ad38167 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.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: tclLiteral.c,v 1.16 2004/07/08 18:46:06 msofer Exp $ + * RCS: @(#) $Id: tclLiteral.c,v 1.17 2004/07/15 17:42:12 msofer Exp $ */ #include "tclInt.h" @@ -731,22 +731,6 @@ TclReleaseLiteral(interp, objPtr) } /* - * Check if the LiteralEntry is only being kept alive by - * a circular reference from a ByteCode stored as its - * internal rep. In that case, set the ByteCode object array - * entry NULL to signal to TclCleanupByteCode to not try to - * release this about to be freed literal again. - */ - - if (objPtr->typePtr == &tclByteCodeType) { - codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr; - if ((codePtr->numLitObjects == 1) - && (codePtr->objArrayPtr[0] == objPtr)) { - codePtr->objArrayPtr[0] = NULL; - } - } - - /* * Remove the reference corresponding to the local literal table * entry. */ |