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

Use a loop to collect args in the parser instead of recursion #85856

Closed
pablogsal opened this issue Sep 2, 2020 · 3 comments
Closed

Use a loop to collect args in the parser instead of recursion #85856

pablogsal opened this issue Sep 2, 2020 · 3 comments
Labels
3.9 only security fixes 3.10 only security fixes

Comments

@pablogsal
Copy link
Member

BPO 41690
Nosy @pablogsal
PRs
  • bpo-41690: Use a loop to collect args in the parser instead of recursion #22053
  • [3.9] bpo-41690: Use a loop to collect args in the parser instead of recursion (GH-22053) #22067
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-09-02.20:31:14.576>
    created_at = <Date 2020-09-02.10:59:21.311>
    labels = ['3.9', '3.10']
    title = 'Use a loop to collect args in the parser instead of recursion'
    updated_at = <Date 2020-09-02.20:31:14.576>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2020-09-02.20:31:14.576>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-09-02.20:31:14.576>
    closer = 'pablogsal'
    components = []
    creation = <Date 2020-09-02.10:59:21.311>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41690
    keywords = ['patch']
    message_count = 3.0
    messages = ['376225', '376255', '376263']
    nosy_count = 1.0
    nosy_names = ['pablogsal']
    pr_nums = ['22053', '22067']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue41690'
    versions = ['Python 3.9', 'Python 3.10']

    @pablogsal
    Copy link
    Member Author

    This program can segfault the parser by stackoverflow:

    import ast
    
    code = "f(" + ",".join(['a' for _ in range(100000)]) + ")"
    print("Ready!")
    ast.parse(code)

    the reason is that the rule for arguments has a simple recursion when collecting args:

    args[expr_ty]:
    [...]
    | a=named_expression b=[',' c=args { c }] {
    [...] }

    Check https://github.com/we-like-parsers/pegen/issues/245 for more context and informaton

    @pablogsal pablogsal added 3.9 only security fixes 3.10 only security fixes labels Sep 2, 2020
    @pablogsal
    Copy link
    Member Author

    New changeset 4a97b15 by Pablo Galindo in branch 'master':
    bpo-41690: Use a loop to collect args in the parser instead of recursion (GH-22053)
    4a97b15

    @pablogsal
    Copy link
    Member Author

    New changeset 8de34cd by Pablo Galindo in branch '3.9':
    [3.9] bpo-41690: Use a loop to collect args in the parser instead of recursion (GH-22053) (GH-22067)
    8de34cd

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant