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

gh-88057: in compile.c, assertion that stackdepth is alway >=0 is missing in one place #96513

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Sep 2, 2022

I believe this assertion would have helped @larryhastings with the crash described in #88057.

@iritkatriel iritkatriel added skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 2, 2022
@larryhastings
Copy link
Contributor

Hmm. Maybe I jumped the gun on approving the merge.

The thing is, in isolation the change is fine. But the code seems a bit weird. Why is there

assert(depth >= 0); /* invalid code or bug in stackdepth() */

on line 7081 in the original source (7082 in the changed source)? depth hasn't changed in the loop yet. Having the assertion here means we only assert the previous change in depth was okay when running the loop--and we don't run the assertion at all after the last instruction.

Without your one-line change, that assertion should really move below depth = new_depth; on line 7092. With your change, I think we can remove that assertion entirely.

I'd also like to see the assertion on target_depth moved up to immediately after the assignment. It's harmless, but pointless, to conditionally set max_depth before doing that check.

@iritkatriel
Copy link
Member Author

Yes, exactly. The assertion on line 7082 was supposed to capture what my new assertion captures, and it does except for the last iteration. We could remove it now, though it's not wrong.

@iritkatriel iritkatriel deleted the assert_depth branch July 25, 2023 18:07
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) skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants