Overview
| Artifact ID: | 7c7315c0f08ae7caffd00ef5a7611ad90416dd75 |
|---|---|
| Ticket: | d4e7780ca1681cd095dbd81fe264feff75c988f7
"global" cmd literal sharing vs. per-interp resolvers |
| User & Date: | gustafn2 on 2016-09-05 22:03:23 |
Changes
- comment changed to:
Cmd literals are shared in the global (i.e. per-interpreter) literal pool per namespace. However, it is not guaranteed, that the cmdObj resolved for a literal via a cmd resolver is the always same for a namespace. Therefore one sees different results for a cmd depending on whether or not the a cmd literal was earlier added to the global cmd literal pool. The global shared cmd literal is taken, the result from the command resolver is ignored. The problem comes from a large real world application during the tcl8.5 -> tcl8.6 transition. The provided patch (see attachment) determines such situations and turns shared global literals into unshared private ones. The provided test cases are trying to reproduce the behavior in a minimalistic setup, which tries to minimalize interactions with other test cases by restricting to certain names. An alternative (but not so local) approach to address these kind of bugs would be to flag during cmd resolution whether a resolved command was derived from a custom cmd resolver, and to prevent the namespace based "global" sharing in such cases based on that flag.
- icomment:
<p>Deleted TclPanic: this was intentionally. When the code is compiled with TCL_COMPILE_DEBUG the function TclVerifyLocalLiteralTable() is called, which tries to make sure that all literals are in the global (sharing) literal pool. It is the intention of the patch to avoid sharing for literals handled by the resolvers, therefore these are not in the global pool, but there is no need to panic in such cases. Actually, the full if-clause should be removed. The change is only visible when compiled with TCL_COMPILE_DEBUG in the resolver.test. <p>Crash: The code had the assumption that all Tcl_Objs of type "cmdName" have a valid intrep. However, SetCmdNameFromAny() can produce a Tcl_Obj of type "cmdName" when the command is not found (last clause of the function). in the tcloo.test, there is some shimmering during compilation, where the literal is found locally with a different type and then SetCmdNameFromAny() changes it. The patch fixes the incorrect assumption. <pre> ================================================================== --- generic/tclObj.c +++ generic/tclObj.c @@ -4218,11 +4218,11 @@ register Namespace *currNsPtr; const char *name; if (objPtr->typePtr == &tclCmdNameType) { resPtr = objPtr->internalRep.twoPtrValue.ptr1; - if (resPtr->cmdPtr == cmdPtr) { + if (resPtr != NULL && resPtr->cmdPtr == cmdPtr) { return; } } cmdPtr->refCount++; </pre> i'll check tomorrow, whether the cleaned-up version is still the same (just noticed changes in flag extra-flag passing). - login: "gustafn2"
- mimetype: "text/html"