GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-47256: re module, limit the maximum capturing group to 1,073,741,823, increasing the depth of backtracking. · Pull Request #32411 · python/cpython

Conversation

@ghost

@ghost ghost commented Apr 8, 2022 •
edited by serhiy-storchaka
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Closes #91412.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting review label Apr 8, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Apr 8, 2022
@serhiy-storchaka
serhiy-storchaka self-requested a review April 11, 2022 08:48
@ghost

ghost commented Apr 12, 2022

Copy link
Copy Markdown
Author

I would like to remove the variable i in the SRE(match) function, just use a few variables with a smaller scope.
This change can be done in this PR or in a code polish PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost mentioned this pull request Apr 15, 2022
gh-91524: Speed up the regular expression substitution #91525
Merged
@serhiy-storchaka serhiy-storchaka added the topic-regex label Apr 15, 2022
serhiy-storchaka
serhiy-storchaka reviewed Apr 15, 2022
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2022-04-08-14-55-55.bpo-47256.X2mFpt.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_sre/sre.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_sre/sre.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Apr 15, 2022

Copy link
Copy Markdown
Member

I would like to remove the variable i in the SRE(match) function, just use a few variables with a smaller scope.

Do it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

wjssz added 4 commits April 16, 2022 13:02
@wjssz
1. limit the maximum capturing group to 1,073,741,823
d13b037
These types are kept as Py_ssize_t:
  - PatternObject.groups
  - MatchObject.lastindex
  - MatchObject.groups

- On 32 bit platform: 36 bytes, no change.  (msvc2022)
- On 64 bit platform: 72 bytes -> 64 bytes. (msvc2022/gcc9.4)
@wjssz
2. further reduce sizeof(SRE(match_context))
8a38ca7
change the type of `SRE(match_context).jump` from Py_ssize_t to int

- On 32 bit platform: 36 bytes, no change.  (msvc2022)
- On 64 bit platform: 64 bytes -> 56 bytes. (msvc2022/gcc9.4)

And make the order of `DO_JUMPX` macro and `SRE(match_context)` struct consistent.
@wjssz
3. MARK_(PUSH|POP) macros compute marks size only once
8cfcab9
DATA_STACK_(PUSH|POP) macros use the size multiple time, now computed value is propagated.
@wjssz
4. remove variable i
11c9ad3
@ghost

ghost commented Apr 16, 2022

Copy link
Copy Markdown
Author

Improved as your comments locally.
If you can find another review, I would like to update this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Apr 16, 2022

Copy link
Copy Markdown
Member

I have no other comments. Please update this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Apr 16, 2022

Copy link
Copy Markdown
Author

I have no other comments. Please update this PR.

I mean reviewer...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed Apr 18, 2022
View reviewed changes
Comment thread Modules/_sre/sre_lib.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@wjssz
Fix indentation
f811dfc
serhiy-storchaka
serhiy-storchaka approved these changes Apr 18, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Apr 18, 2022
@serhiy-storchaka
serhiy-storchaka merged commit a29f858 into python:main Apr 18, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 18, 2022
@ghost
ghost deleted the context_size branch April 18, 2022 14:03
@animalize animalize mannequin mentioned this pull request Apr 13, 2022
re: limit the maximum capturing group to 1,073,741,823, reduce sizeof(match_context). #91412
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-regex

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

re: limit the maximum capturing group to 1,073,741,823, reduce sizeof(match_context).

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@serhiy-storchaka @the-knights-who-say-ni @bedevere-bot @wjssz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.