From df6dfc34691563ae25dc7970f47e3b29c66c4dec Mon Sep 17 00:00:00 2001 From: andreask Date: Mon, 21 Nov 2011 18:23:16 +0000 Subject: Fix a bug where global precompiled code (A) called from a precompiled procedure causes the core to recompile (A), triggering the trap laid inside, i.e. 'error "called a copy of compiled code"'.
Example
----------------------ex1.tcl
proc init {} {
    source ex2.tcl
}
init
----------------------ex2.tcl
puts a
----------------------
When run as precompiled code the 'puts a' is not executed, only the trap. Fixed by enclosing the offending code into a guard which prevents its execution for precompiled code. The change passes the entire testsuite. --- generic/tclExecute.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 953c63e..b7c576a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1652,14 +1652,16 @@ TclCompileObj( } } - if (codePtr->procPtr == NULL) { - /* - * Check that any compiled locals do refer to the current proc - * environment! If not, recompile. - */ + if (!(codePtr->flags & TCL_BYTECODE_PRECOMPILED)) { + if (codePtr->procPtr == NULL) { + /* + * Check that any compiled locals do refer to the current proc + * environment! If not, recompile. + */ - if (codePtr->localCachePtr != iPtr->varFramePtr->localCachePtr) { - goto recompileObj; + if (codePtr->localCachePtr != iPtr->varFramePtr->localCachePtr) { + goto recompileObj; + } } } -- cgit v0.12