Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation stack bounds are not checked in debug builds. #120982

Closed
markshannon opened this issue Jun 25, 2024 · 0 comments
Closed

Evaluation stack bounds are not checked in debug builds. #120982

markshannon opened this issue Jun 25, 2024 · 0 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@markshannon
Copy link
Member

markshannon commented Jun 25, 2024

Bug report

Bug description:

Prior to the generating code for the interpreter(s), we had a set of macros for stack manipulation, PUSH, POP, etc.
The code generator does not use these any more, which improves readability, but we have lost the runtime checking of bounds.
Having those bounds checks would have identified the issue with #120793 almost immediately.

We should add bounds checking asserts in the generated code.
E.g.
stack_pointer +=1 should be

stack_pointer += 1;
assert(WITH_STACK_BOUNDS(stack_pointer));

This bulks out the generated code a bit, but I think making the limit checks explicit is more readable than using stack adjustment macros.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant