Skip to content

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

Closed

Description

@pablogsal
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']

    Activity

    1. pablogsal commented on Sep 2, 2020

      @pablogsal
      MemberAuthor

      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

    2. pablogsal commented on Sep 2, 2020

      @pablogsal
      MemberAuthor

      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

    3. pablogsal commented on Sep 2, 2020

      @pablogsal
      MemberAuthor

      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

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions