summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-07-03 20:28:27 (GMT)
committerGitHub <noreply@github.com>2023-07-03 20:28:27 (GMT)
commite5862113dde7a66b08f1ece542a3cfaf0a3d9080 (patch)
tree1085ca157fffe2548dcdc6227515f19329a6ef8d /Python/bytecodes.c
parent7f4c8121db62a9f72f00f2d9f73381e82f289581 (diff)
downloadcpython-e5862113dde7a66b08f1ece542a3cfaf0a3d9080.zip
cpython-e5862113dde7a66b08f1ece542a3cfaf0a3d9080.tar.gz
cpython-e5862113dde7a66b08f1ece542a3cfaf0a3d9080.tar.bz2
GH-104584: Fix ENTER_EXECUTOR (GH-106141)
* Check eval-breaker in ENTER_EXECUTOR. * Make sure that frame->prev_instr is set before entering executor.
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 8aab7eb..f69ac2b 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -141,8 +141,8 @@ dummy_func(
ERROR_IF(err, error);
next_instr--;
}
- else if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
- goto handle_eval_breaker;
+ else if (oparg < 2) {
+ CHECK_EVAL_BREAKER();
}
}
@@ -158,6 +158,9 @@ dummy_func(
next_instr--;
}
else {
+ if (oparg < 2) {
+ CHECK_EVAL_BREAKER();
+ }
_PyFrame_SetStackPointer(frame, stack_pointer);
int err = _Py_call_instrumentation(
tstate, oparg > 0, frame, next_instr-1);
@@ -168,9 +171,6 @@ dummy_func(
next_instr = frame->prev_instr;
DISPATCH();
}
- if (_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker) && oparg < 2) {
- goto handle_eval_breaker;
- }
}
}
@@ -2223,6 +2223,7 @@ dummy_func(
}
inst(JUMP_BACKWARD, (--)) {
+ CHECK_EVAL_BREAKER();
_Py_CODEUNIT *here = next_instr - 1;
assert(oparg <= INSTR_OFFSET());
JUMPBY(1-oparg);
@@ -2240,7 +2241,6 @@ dummy_func(
goto resume_frame;
}
#endif /* ENABLE_SPECIALIZATION */
- CHECK_EVAL_BREAKER();
}
pseudo(JUMP) = {
@@ -2254,8 +2254,13 @@ dummy_func(
};
inst(ENTER_EXECUTOR, (--)) {
+ CHECK_EVAL_BREAKER();
+
PyCodeObject *code = _PyFrame_GetCode(frame);
_PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255];
+ int original_oparg = executor->vm_data.oparg | (oparg & 0xfffff00);
+ JUMPBY(1-original_oparg);
+ frame->prev_instr = next_instr - 1;
Py_INCREF(executor);
frame = executor->execute(executor, frame, stack_pointer);
if (frame == NULL) {
@@ -3570,8 +3575,8 @@ dummy_func(
}
inst(INSTRUMENTED_JUMP_BACKWARD, ( -- )) {
- INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP);
CHECK_EVAL_BREAKER();
+ INSTRUMENTED_JUMP(next_instr-1, next_instr+1-oparg, PY_MONITORING_EVENT_JUMP);
}
inst(INSTRUMENTED_POP_JUMP_IF_TRUE, ( -- )) {