Skip to content

Commit b4434ad

Browse files
Check recursion limit in _PY_FRAME_GENERAL
1 parent 71da68d commit b4434ad

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_opcache.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,13 @@ def instantiate():
550550
with self.assertRaises(TypeError):
551551
instantiate()
552552

553+
def test_recursion_check_for_general_calls(self):
554+
def test(default=None):
555+
return test()
556+
557+
with self.assertRaises(RecursionError):
558+
test()
559+
553560

554561
def make_deferred_ref_count_obj():
555562
"""Create an object that uses deferred reference counting.

Python/bytecodes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,7 @@ dummy_func(
37563756
macro(INSTRUMENTED_CALL) = unused/3 + _MAYBE_EXPAND_METHOD + _MONITOR_CALL + _DO_CALL + _CHECK_PERIODIC;
37573757

37583758
op(_PY_FRAME_GENERAL, (callable, self_or_null, args[oparg] -- new_frame: _PyInterpreterFrame*)) {
3759+
DEOPT_IF(tstate->py_recursion_remaining <= 1);
37593760
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
37603761

37613762
// oparg counts all of the args, but *not* self:

Python/executor_cases.c.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)