Kaydet (Commit) ee65e226 authored tarafından Neal Norwitz's avatar Neal Norwitz

Fix bug introduced by SF patch #643835, Set Next Statement for Python debuggers

blockstack_top could be 0 when blockstack[blockstack_top-1]
was referenced (ie blockstack[-1]) which crashed on hpux.
Patch & fix by Richie Hindle
üst 7e4cfcb6
...@@ -184,6 +184,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) ...@@ -184,6 +184,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
break; break;
case POP_BLOCK: case POP_BLOCK:
assert(blockstack_top > 0);
setup_op = code[blockstack[blockstack_top-1]]; setup_op = code[blockstack[blockstack_top-1]];
if (setup_op == SETUP_FINALLY) { if (setup_op == SETUP_FINALLY) {
in_finally[blockstack_top-1] = 1; in_finally[blockstack_top-1] = 1;
...@@ -196,11 +197,14 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) ...@@ -196,11 +197,14 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
case END_FINALLY: case END_FINALLY:
/* Ignore END_FINALLYs for SETUP_EXCEPTs - they exist /* Ignore END_FINALLYs for SETUP_EXCEPTs - they exist
* in the bytecode but don't correspond to an actual * in the bytecode but don't correspond to an actual
* 'finally' block. */ * 'finally' block. (If blockstack_top is 0, we must
* be seeing such an END_FINALLY.) */
if (blockstack_top > 0) {
setup_op = code[blockstack[blockstack_top-1]]; setup_op = code[blockstack[blockstack_top-1]];
if (setup_op == SETUP_FINALLY) { if (setup_op == SETUP_FINALLY) {
blockstack_top--; blockstack_top--;
} }
}
break; break;
} }
...@@ -233,6 +237,10 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) ...@@ -233,6 +237,10 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
} }
} }
/* Verify that the blockstack tracking code didn't get lost. */
assert(blockstack_top == 0);
/* After all that, are we jumping into / out of a 'finally' block? */
if (new_lasti_setup_addr != f_lasti_setup_addr) { if (new_lasti_setup_addr != f_lasti_setup_addr) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"can't jump into or out of a 'finally' block"); "can't jump into or out of a 'finally' block");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment