Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lib/test/test_generated_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ def test_validate_uop_unused_input(self):
output = """
case OP: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
CHECK_STACK_BOUNDS();
break;
}
"""
Expand All @@ -2133,7 +2133,7 @@ def test_validate_uop_unused_input(self):
output = """
case OP: {
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
CHECK_STACK_BOUNDS();
break;
}
"""
Expand All @@ -2155,7 +2155,7 @@ def test_validate_uop_unused_output(self):
foo = NULL;
stack_pointer[0] = foo;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
CHECK_STACK_BOUNDS();
break;
}
"""
Expand All @@ -2173,7 +2173,7 @@ def test_validate_uop_unused_output(self):
output = """
case OP: {
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
CHECK_STACK_BOUNDS();
break;
}
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check against abstract stack overflow in the JIT optimizer.
11 changes: 7 additions & 4 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ incorrect_keys(PyObject *obj, uint32_t version)

#define CURRENT_FRAME_IS_INIT_SHIM() (ctx->frame->code == ((PyCodeObject *)&_Py_InitCleanup))

#define WITHIN_STACK_BOUNDS() \
(CURRENT_FRAME_IS_INIT_SHIM() || (STACK_LEVEL() >= 0 && STACK_LEVEL() <= STACK_SIZE()))


#define GETLOCAL(idx) ((ctx->frame->locals[idx]))

#define REPLACE_OP(INST, OP, ARG, OPERAND) \
Expand Down Expand Up @@ -191,6 +187,13 @@ incorrect_keys(PyObject *obj, uint32_t version)
#define sym_new_truthiness _Py_uop_sym_new_truthiness

#define JUMP_TO_LABEL(label) goto label;
#define CHECK_STACK_BOUNDS() do { \
if (!CURRENT_FRAME_IS_INIT_SHIM() && (STACK_LEVEL() < 0 || STACK_LEVEL() > STACK_SIZE())) { \
ctx->contradiction = true; \
ctx->done = true; \
break; \
} \
} while (0);

static int
optimize_to_bool(
Expand Down
Loading
Loading