summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclExecute.c19
-rw-r--r--tests/nre.test19
3 files changed, 34 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fec71e..72138dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-03-21 Miguel Sofer <msofer@users.sf.net>
+ * generic/tclExecute.c: proper fix for [Bug 2415422]. Reenabled
+ * tests/nre.test: the failing assertion that was disabled on
+ 2008-12-18: the assertion is correct, the fault was in the
+ management of expansions.
+
* generic/tclExecute.c: fix both test and code for tailcall
* tests/tailcall.test: from within a compiled [eval] body.
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 56bace2..99bf84e 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.431 2009/03/21 03:43:53 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.432 2009/03/21 06:55:31 msofer Exp $
*/
#include "tclInt.h"
@@ -1987,9 +1987,7 @@ TclExecuteByteCode(
* reset, now process the return.
*/
- /* Disabled the following assertion to solve the trouble reported
- * in Tcl Bug 2415422. Needs review. */
- /*NRE_ASSERT(iPtr->cmdFramePtr == bcFramePtr);*/
+ NRE_ASSERT(iPtr->cmdFramePtr == bcFramePtr);
iPtr->cmdFramePtr = bcFramePtr->nextPtr;
/*
@@ -2592,15 +2590,20 @@ TclExecuteByteCode(
if (moved) {
/*
- * Change the global data to point to the new stack.
+ * Change the global data to point to the new stack: move the
+ * bottomPtr, recompute the position of every other
+ * stack-allocated parameter, update the stack pointers.
*/
bottomPtr = (BottomData *) (((Tcl_Obj **)bottomPtr) + moved);
- initCatchTop += moved;
+
+ bcFramePtr = (CmdFrame *) (bottomPtr + 1);
+ initCatchTop = ((ptrdiff_t *) (bcFramePtr + 1)) - 1;
+ initTosPtr = (Tcl_Obj **) (initCatchTop + codePtr->maxExceptDepth);
+ esPtr = iPtr->execEnvPtr->execStackPtr;
+
catchTop += moved;
- initTosPtr += moved;
tosPtr += moved;
- esPtr = iPtr->execEnvPtr->execStackPtr;
}
/*
diff --git a/tests/nre.test b/tests/nre.test
index dd86e18..e823234 100644
--- a/tests/nre.test
+++ b/tests/nre.test
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: nre.test,v 1.8 2009/02/02 06:02:41 dgp Exp $
+# RCS: @(#) $Id: nre.test,v 1.9 2009/03/21 06:55:32 msofer Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -304,6 +304,23 @@ test nre-8.1 {nre and {*}} -body {
rename inner {}
rename outer {}
} -result {1 1 1}
+test nre-8.2 {nre and {*}, [Bug 2415422]} -body {
+ # force an expansion that grows the evaluation stack, check that nre
+ # adapts the bcFramePtr. This causes an NRE assertion to fail if it is not
+ # done properly.
+
+ proc nop {} {}
+ proc crash {} {
+ foreach val [list {*}[lrepeat 100000 x]] {
+ nop
+ }
+ }
+
+ crash
+} -cleanup {
+ rename nop {}
+ rename crash {}
+}
#