Skip to content

Commit 85f8e76

Browse files
[3.13] gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS (GH-145015)
1 parent 702d085 commit 85f8e76

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Include/internal/pycore_opcode_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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug when calling certain methods at the recursion limit which manifested as a corruption of Python's operand stack. Patch by Ken Jin.

Python/bytecodes.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3241,9 +3241,11 @@ dummy_func(
32413241
macro(CALL_BOUND_METHOD_GENERAL) =
32423242
unused/1 + // Skip over the counter
32433243
_CHECK_PEP_523 +
3244+
// gh-145008: We must check recursion before expanding method,
3245+
// otherwise we may leave the stack in an inconsistent state in 3.13.
3246+
_CHECK_RECURSION_REMAINING +
32443247
_CHECK_METHOD_VERSION +
32453248
_EXPAND_METHOD +
3246-
_CHECK_RECURSION_REMAINING +
32473249
_PY_FRAME_GENERAL +
32483250
_SAVE_RETURN_OFFSET +
32493251
_PUSH_FRAME;

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)