summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-12-19 04:11:07 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-12-19 04:11:07 (GMT)
commitb6d14daa1c48d8938a140a671bcd17cb40cdd54d (patch)
tree9ba1ab3af516fb83c545a74d9acb741308ff64e5
parent81b61bdc1a0c73f843ec5c8321fda3b52541c8d8 (diff)
downloadcpython-b6d14daa1c48d8938a140a671bcd17cb40cdd54d.zip
cpython-b6d14daa1c48d8938a140a671bcd17cb40cdd54d.tar.gz
cpython-b6d14daa1c48d8938a140a671bcd17cb40cdd54d.tar.bz2
SF bug #494668: PUSH() should assert-fail on overflow.
eval_frame(): Added asserts to the top of the eval loop, to verify that the eval stack pointer is in bounds, plus some comments.
-rw-r--r--Python/ceval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 94cf17e..2feb123 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -497,7 +497,7 @@ eval_frame(PyFrameObject *f)
#ifdef DXPAIRS
int lastopcode = 0;
#endif
- PyObject **stack_pointer;
+ PyObject **stack_pointer; /* Next free slot in value stack */
register unsigned char *next_instr;
register int opcode=0; /* Current opcode */
register int oparg=0; /* Current opcode argument, if any */
@@ -586,7 +586,7 @@ eval_frame(PyFrameObject *f)
next_instr = first_instr + f->f_lasti;
stack_pointer = f->f_stacktop;
assert(stack_pointer != NULL);
- f->f_stacktop = NULL;
+ f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */
if (tstate->use_tracing) {
if (tstate->c_tracefunc != NULL) {
@@ -634,6 +634,8 @@ eval_frame(PyFrameObject *f)
w = NULL;
for (;;) {
+ assert(stack_pointer >= f->f_valuestack); /* else underflow */
+ assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */
/* Do periodic things. Doing this every time through
the loop would add too much overhead, so we do it
only every Nth instruction. We also do it if