summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormig <mig>2013-01-05 03:43:05 (GMT)
committermig <mig>2013-01-05 03:43:05 (GMT)
commita9a9afc838c1d357e9a50c1045a90276f49edb42 (patch)
treea526629db720d56fb03f755be004c02ed6b97d35
parentd3a8deb1536f2aa1c1015187dd7d0330a596aeab (diff)
downloadtcl-a9a9afc838c1d357e9a50c1045a90276f49edb42.zip
tcl-a9a9afc838c1d357e9a50c1045a90276f49edb42.tar.gz
tcl-a9a9afc838c1d357e9a50c1045a90276f49edb42.tar.bz2
improved stack checking under TCL_COMPILE_DEBUG
-rw-r--r--generic/tclExecute.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index fbf8f6d..8759ec9 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -259,7 +259,8 @@ VarHashCreateVar(
#if TCL_COMPILE_DEBUG
#define CHECK_STACK() \
- assert((auxObjList != NULL) || (CURR_DEPTH <= codePtr->maxStackDepth))
+ ValidatePcAndStackTop(codePtr, pc, CURR_DEPTH, \
+ /*checkStack*/ auxObjList == NULL)
#else
#define CHECK_STACK()
#endif
@@ -696,7 +697,7 @@ static void PrintByteCodeInfo(ByteCode *codePtr);
static const char * StringForResultCode(int result);
static void ValidatePcAndStackTop(ByteCode *codePtr,
const unsigned char *pc, int stackTop,
- int stackLowerBound, int checkStack);
+ int checkStack);
#endif /* TCL_COMPILE_DEBUG */
static ByteCode * CompileExprObj(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void DeleteExecStack(ExecStack *esPtr);
@@ -2254,8 +2255,7 @@ TEBCresume(
* Skip the stack depth check if an expansion is in progress.
*/
- ValidatePcAndStackTop(codePtr, pc, CURR_DEPTH, 0,
- /*checkStack*/ auxObjList == NULL);
+ CHECK_STACK();
if (traceInstructions) {
fprintf(stdout, "%2d: %2d ", iPtr->numLevels, (int) CURR_DEPTH);
TclPrintInstruction(codePtr, pc);
@@ -8571,11 +8571,10 @@ ValidatePcAndStackTop(
int stackTop, /* Current stack top. Must be between
* stackLowerBound and stackUpperBound
* (inclusive). */
- int stackLowerBound, /* Smallest legal value for stackTop. */
int checkStack) /* 0 if the stack depth check should be
* skipped. */
{
- int stackUpperBound = stackLowerBound + codePtr->maxStackDepth;
+ int stackUpperBound = codePtr->maxStackDepth;
/* Greatest legal value for stackTop. */
unsigned relativePc = (unsigned) (pc - codePtr->codeStart);
unsigned long codeStart = (unsigned long) codePtr->codeStart;
@@ -8593,13 +8592,13 @@ ValidatePcAndStackTop(
(unsigned) opCode, relativePc);
Tcl_Panic("TclNRExecuteByteCode execution failure: bad opcode");
}
- if (checkStack &&
- ((stackTop < stackLowerBound) || (stackTop > stackUpperBound))) {
+ if (checkStack &&
+ ((stackTop < 0) || (stackTop > stackUpperBound))) {
int numChars;
const char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars, NULL);
- fprintf(stderr, "\nBad stack top %d at pc %u in TclNRExecuteByteCode (min %i, max %i)",
- stackTop, relativePc, stackLowerBound, stackUpperBound);
+ fprintf(stderr, "\nBad stack top %d at pc %u in TclNRExecuteByteCode (min 0, max %i)",
+ stackTop, relativePc, stackUpperBound);
if (cmd != NULL) {
Tcl_Obj *message;