Skip to content

gh-93671: Avoid exponential backtracking in deeply nested sequence patterns in match statements - #93680

Merged
ambv merged 2 commits into
python:mainfrom
pablogsal:gh-93671
Jun 10, 2022
Merged

ambv merged 2 commits into
python:mainfrom
pablogsal:gh-93671

Conversation

@pablogsal

@pablogsal pablogsal commented Jun 10, 2022 •

Copy link
Copy Markdown
Member

closes: #93671

@Fidget-Spinner

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Member

Should there be a test for this?

@pablogsal

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Member Author

Should there be a test for this?

I submitted the PR so we can start checking that it works in other cases.

I will be adding a bunch of cases, but the tests are limited because there is nothing crashing, although I can add a bunch of cases that would take years to succeed.

@ambv

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Contributor

I can confirm that the new test just doesn't finish on main without the patch. Since this is in the parser, it's also not something you can easily CTRL-C out of 😆

@ambv
ambv merged commit 53a8b17 into python:main Jun 10, 2022
@miss-islington

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Contributor

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

@miss-islington

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Contributor

Sorry, @pablogsal and @ambv, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 53a8b17895e91d08f76a2fb59a555d012cd85ab4 3.10

@bedevere-bot

ghost commented Jun 10, 2022

Copy link
Copy Markdown

GH-93689 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 Jun 10, 2022
@pablogsal

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Member Author

Are you preparing the backport or should I do it? @ambv

@pablogsal
pablogsal deleted the gh-93671 branch June 10, 2022 17:58
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jun 10, 2022
@bedevere-bot

ghost commented Jun 10, 2022

Copy link
Copy Markdown

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

@brandtbucher

ghost commented Jun 10, 2022

Copy link
Copy Markdown
Member

Thanks for the quick fix, @pablogsal!

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.

Python3.10.5 Pattern Matching Excessive Memory Consumption

6 participants