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-95185: Check recursion depth in the AST constructor #95186

Merged
merged 3 commits into from Jul 24, 2022

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jul 23, 2022

Closes: #95185

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@graingert
Copy link
Contributor

@graingert graingert commented Jul 23, 2022

A similar issue didn't get backported to 3.9 #25634

@pablogsal
Copy link
Member Author

@pablogsal pablogsal commented Jul 24, 2022

A similar issue didn't get backported to 3.9 #25634

We may need to discuss this (check PSRT @ambv)

Parser/asdl_c.py Show resolved Hide resolved
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Since the code is generated and functions only have one exit on failure, you can add state->recursion_depth-- also for failure, and check the balance on failure too, as in symtable, etc.

I did not decremented the recursion depth on failure in ast_opt because functions there have multiple failure exits, so it would complicate the code. But in this case it will complicate the code.

Parser/asdl_c.py Outdated Show resolved Hide resolved
Parser/asdl_c.py Outdated Show resolved Hide resolved
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

In any case LGTM.

pablogsal and others added 2 commits Jul 24, 2022
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@pablogsal pablogsal merged commit 0047447 into python:main Jul 24, 2022
14 checks passed
@pablogsal pablogsal deleted the recursion branch Jul 24, 2022
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 24, 2022

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 24, 2022
…H-95186)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 00474472944944b346d8409cfded84bb299f601a)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 24, 2022

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

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 24, 2022

Sorry, @pablogsal, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 00474472944944b346d8409cfded84bb299f601a 3.10

pablogsal added a commit to pablogsal/cpython that referenced this issue Jul 24, 2022
…ythonGH-95186)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>.
(cherry picked from commit 0047447)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 24, 2022

GH-95209 is a backport of this pull request to the 3.10 branch.

pablogsal added a commit to pablogsal/cpython that referenced this issue Jul 24, 2022
…ythonGH-95186)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>.
(cherry picked from commit 0047447)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@python python deleted a comment from bedevere-bot Jul 24, 2022
@ambv
Copy link
Contributor

@ambv ambv commented Jul 25, 2022

A similar issue didn't get backported to 3.9 #25634

We may need to discuss this (check PSRT @ambv)

@pablogsal, since you aborted backporting GH-95186 (this PR) to 3.10 due to the ABI change, do you still think I should be backporting GH-25634, which I aborted due to ABI changes?

@pablogsal
Copy link
Member Author

@pablogsal pablogsal commented Jul 25, 2022

A similar issue didn't get backported to 3.9 #25634

We may need to discuss this (check PSRT @ambv)

@pablogsal, since you aborted backporting GH-95186 (this PR) to 3.10 due to the ABI change, do you still think I should be backporting GH-25634, which I aborted due to ABI changes?

The ABI is changing but I don't think is in a way that can break things in extension modules. It may break profilers and debuggers thought.

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.

7 participants