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-94445: add compiler test for another case of excessive stack use #99237

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

carljm
Copy link
Member

@carljm carljm commented Nov 8, 2022

In GH-94329 the MAX_ALLOWED_STACK_SIZE check in the compiler (added in 3.10.0) was reverted,
because it was discovered that a large sequence unpacking could use more than the allowed stack size.
A todo comment was left in the code to re-add this check in future, and GH-94445 was created to track
the todo item.

I've found another case in which unbounded stack can be consumed: a function with a very large number
of type-annotated arguments. This PR simply adds a test for that case, to ensure that if in future the
stack-size check is again enforced, the case won't be missed and cause another breakage for valid (if
pathological) code.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Nov 8, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull request Nov 8, 2022
Summary:
3.10 added a new check in the compiler to error if a maximum
stack size was exceeded, on the (mistaken) assumption that all
cases in the compiler that could lead to very large stack sizes
had been fixed. Later it was realized that large stack sizes were
still possible, so this check was reverted (in 3.10.6+, 3.11, and
3.12.) Backport the revert to our 3.10 (which is based on 3.10.5.)

There might be an argument for updating our 3.10 to the latest
upstream 3.10 branch (or latest 3.10 minor release) to bring in
more of these bugfixes and compatibility fixes before we have to
hit them ourselves. But this might also bring conflict-resolution
hassles for bugs we wouldn't even be affected by. For now, just
backport this one fix.

Also submitted python/cpython#99237
upstream to ensure this case isn't missed if/when the max stack
size check is re-added in 3.12.

Reviewed By: itamaro

Differential Revision: D41111919

fbshipit-source-id: 5480357
@carljm carljm requested a review from iritkatriel November 8, 2022 20:10
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iritkatriel iritkatriel added the needs backport to 3.11 only security fixes label Nov 8, 2022
@iritkatriel iritkatriel merged commit 027bc7e into python:main Nov 8, 2022
@miss-islington
Copy link
Contributor

Thanks @carljm for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 8, 2022
@bedevere-bot
Copy link

GH-99262 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Nov 8, 2022
miss-islington added a commit that referenced this pull request Nov 8, 2022
@carljm carljm deleted the testbigfunc branch April 7, 2023 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants