-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-141976: Check stack bounds in JIT optimizer #142201
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the extra code in optimizer_genrator.py when we're just changing assert(WITHIN_STACK_BOUNDS()) to CHECK_STACK_BOUNDS()?
You can reduce the amount of extra code by making the assertion/check code an attribute of the Stack object.
markshannon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One piece of code left from the earlier version that should be removed.
Otherwise, LGTM.
| def emit_save(self, storage: Storage) -> None: | ||
| storage.flush(self.out) | ||
|
|
||
| def sync_sp( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now just a copy of the overridden method, so it can be removed.
|
When you're done making the requested changes, leave the comment: |
|
Actually, there's a serious flaw with this approach. It should be checking the stack bound before we write and increment the stack pointer. Otherwise, we might be writing to invalid memory. |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @markshannon: please review the changes made to this pull request. |
markshannon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The extra checks probably aren't strictly necessary for safety, since we are writing into the middle of a huge buffer.
But, they're not wrong and a bit of extra safety is a good thing.
I verified this fixes the repro given in the issue. I'm not adding the repro because it's not self-contained, and so might change if asyncio changes.
WITHIN_STACK_BOUNDS()inoptimize_uops#141976