Skip to content

[3.13] gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS#145015

Merged
Fidget-Spinner merged 5 commits intopython:3.13from
Fidget-Spinner:3.13_recursion_inconsistency_fix
Mar 2, 2026
Merged

[3.13] gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS#145015
Fidget-Spinner merged 5 commits intopython:3.13from
Fidget-Spinner:3.13_recursion_inconsistency_fix

Conversation

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Feb 19, 2026

The problem is that 3.13 actually doesn't guarantee stack consistency always between uops. This manifests as a bug that seems like stack corruption. In 3.14 and 3.15, this isn't a problem because we guarantee stack consistency between uops always by flushing or otherwise. The bandaid for 3.13 is to move all deopts to before we modify the stack.

@marc-hb could you please try the patch and check if it fixes your code? I tried on my end and it does, just need a second checker.

Can't test this easily, as it depends on specific recursion limits and interaction of specialization.

@Fidget-Spinner Fidget-Spinner changed the title gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS [3.13] gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS Feb 19, 2026
@marc-hb
Copy link

marc-hb commented Feb 19, 2026

I cherry-picked the single commit 58c2e83 from this PR on top of v3.13.12 and I can confirm that this solves my issue #145008 and makes that infinite recursion test pass.

(Not like this should matter much but I also ran the other, non-recursive tests in the suite while at it and nothing went wrong)

@encukou
Copy link
Member

encukou commented Mar 2, 2026

This looks fine to me but I don't know enough about the JIT to review in depth.

@Fidget-Spinner
Copy link
Member Author

JIT tests are failing, no clue why. However, since 3.13 JIT is experimental and pretty much no one uses it, I'll ignore it for now. @encukou this isn't a JIT failure but an actual interpreter crash.

@Fidget-Spinner Fidget-Spinner merged commit 85f8e76 into python:3.13 Mar 2, 2026
59 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants