New submission from Pablo Galindo Salgado <pablog...@gmail.com>:

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

----------
messages: 376225
nosy: pablogsal
priority: normal
severity: normal
status: open
title: Use a loop to collect args in the parser instead of recursion
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41690>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to