gh-132744: Check recursion limit in CALL_PY_GENERAL (GH-132746)

This commit is contained in:
Ken Jin 2025-05-03 00:36:29 +08:00 committed by GitHub
parent 987e45e632
commit ddac7ac59a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 220 additions and 170 deletions

View file

@ -3858,6 +3858,7 @@ dummy_func(
unused/1 + // Skip over the counter
_CHECK_PEP_523 +
_CHECK_FUNCTION_VERSION +
_CHECK_RECURSION_REMAINING +
_PY_FRAME_GENERAL +
_SAVE_RETURN_OFFSET +
_PUSH_FRAME;
@ -3889,6 +3890,7 @@ dummy_func(
_CHECK_METHOD_VERSION +
_EXPAND_METHOD +
flush + // so that self is in the argument array
_CHECK_RECURSION_REMAINING +
_PY_FRAME_GENERAL +
_SAVE_RETURN_OFFSET +
_PUSH_FRAME;
@ -3967,6 +3969,9 @@ dummy_func(
PyFunctionObject *func = (PyFunctionObject *)callable_o;
PyCodeObject *code = (PyCodeObject *)func->func_code;
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
}
op(_CHECK_RECURSION_REMAINING, (--)) {
DEOPT_IF(tstate->py_recursion_remaining <= 1);
}
@ -4008,6 +4013,7 @@ dummy_func(
_CHECK_FUNCTION_VERSION +
_CHECK_FUNCTION_EXACT_ARGS +
_CHECK_STACK_SPACE +
_CHECK_RECURSION_REMAINING +
_INIT_CALL_PY_EXACT_ARGS +
_SAVE_RETURN_OFFSET +
_PUSH_FRAME;
@ -4018,6 +4024,7 @@ dummy_func(
_CHECK_FUNCTION_VERSION +
_CHECK_FUNCTION_EXACT_ARGS +
_CHECK_STACK_SPACE +
_CHECK_RECURSION_REMAINING +
_INIT_CALL_PY_EXACT_ARGS +
_SAVE_RETURN_OFFSET +
_PUSH_FRAME;