Batuhan Taskaya <isidenti...@gmail.com> added the comment:
> With 3.9 on Windows, using Benjamin's example, I do not get the Windows > equivalent of a seg fault. However, execution stops at compile with no > exception, including SystemExit. I can still reproduce on Linux, $ python Python 3.10.0a0 (heads/bpo-xxxxx:f2947e354c, May 21 2020, 18:54:57) [GCC 9.2.1 20191008] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) >>> e.operand = e >>> compile(ast.Expression(e), "<test>", "eval") [1] 15320 segmentation fault (core dumped) python > These examples amount to limited fuzz testing of compile(). I think it > should raise something like "SyntaxError: recursive ast" or even 'bad ast' if > malformed non-recursive asts have the same issue. I dont think it would be easy to locate such errors before they happen, instead I propose (actually already proposed in PR 20594) to add recursion guards to places where this might happen. This can prevent crashes on both direct and indirect cycles >>> import ast >>> e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) >>> e.operand = e >>> compile(ast.Expression(e), "<test>", "eval") Traceback (most recent call last): File "<stdin>", line 1, in <module> RecursionError: maximum recursion depth exceeded while traversing 'expr' node >>> e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) >>> f = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0) >>> e.operand = f >>> f.operand = e >>> compile(ast.Expression(e), "<test>", "eval") Traceback (most recent call last): File "<stdin>", line 1, in <module> RecursionError: maximum recursion depth exceeded while traversing 'expr' node ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue11105> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com