Artifacts Associated With Ticket 218535
Ticket change [186e9e6df0] (rid 122657) by nobody on 2000-10-26 01:01:52:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 928 Bug Version: 8.0.4 SubmitDate: '1998-12-04' LastModified: '1999-02-02' Severity: SER Status: Released Submitter: welch ChangedBy: stanton OS: Solaris Machine: Other FixedDate: '1999-02-02' FixedInVersion: 8.0.5 ClosedDate: '2000-10-25' Name: Felix Lee CVS: tclCompile.c,v 1.11 1998/09/14 18:39:58 ReproducibleScript: running the following script will cause a seg fault or some such. set x {{0}} while {1} { if !$x {puts yes} } what happens is the bytecode interpreter overruns the catch stack, because the compiled code is missing an endCatch. Patch: Index: tclCompile.c =================================================================== RCS file: /cvsroot/tcl/generic/tclCompile.c,v retrieving revision 1.11 diff -c -p -r1.11 tclCompile.c *** tclCompile.c1998/09/14 18:39:581.11 --- tclCompile.c1998/11/27 03:04:26 *************** *** 5,11 **** *of commands (like quoted strings or nested sub-commands) into a *sequence of instructions ("bytecodes"). * ! * Copyright (c) 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. --- 5,11 ---- *of commands (like quoted strings or nested sub-commands) into a *sequence of instructions ("bytecodes"). * ! * Copyright (c) 1996-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. *************** CompileExprWord(interp, string, lastChar *** 6321,6329 **** envPtr->excRangeArrayNext = startRangeNext; inlineCode = 0; } else { ! TclEmitOpcode(INST_END_CATCH, envPtr); TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP, &jumpFixup); envPtr->excRangeArrayPtr[range].catchOffset = TclCurrCodeOffset(); } } --- 6321,6330 ---- envPtr->excRangeArrayNext = startRangeNext; inlineCode = 0; } else { ! TclEmitOpcode(INST_END_CATCH, envPtr); /* for ok case */ TclEmitForwardJump(envPtr, TCL_UNCONDITIONAL_JUMP, &jumpFixup); envPtr->excRangeArrayPtr[range].catchOffset = TclCurrCodeOffset(); + TclEmitOpcode(INST_END_CATCH, envPtr); /* for error case */ } } PatchFiles: tcl/generic/tclCompile.c note, this code in CompileExprWord() is analagous to code in TclCompileExprCmd(), which is already correct. tests/if.test probably needs a few testcases added, since only a few of the if-expression optimizations ever get exercised. and in general, this type of stack-overflow error won't be caught by the testsuite, since few of the tests live long enough to seriously overflow the stack. - foundin initialized to: "obsolete: 8.0.4"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "compiler emits bad code for "if" expressions"
- type initialized to: "Bug"
Ticket change [3174cae3bf] (rid 93430) by welch on 2000-10-26 08:24:12:
- closedate changed to: "2000-10-26T01:24:12"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [9227df4f6a] (rid 120729) by dgp on 2001-04-16 23:30:11:
- closedate changed to: "2001-04-16T16:30:11"
- closer changed to: "dgp"
- subsystem changed to: "47. Bytecode Compiler"
- title changed to: "compiler emits bad code for "if" expressions"