New submission from Xinmeng Xia <xi...@smail.nju.edu.cn>:
Calling function ast.parse() with large size can cause a segmentation fault in Python 3.5 -3.10. Please check the following two examples. The example 1 works as expected, while the second one triggers segmentation fault on Python 3.5,3.6,3.7,3.8,3.9,3.10. The primary difference between these two examples lay on the value of "n". Example 1: ========================================= import ast mylist = [] n = 100000 print(ast.parse("mylist"+"+mylist"*n)) ========================================== The actual output: AST nodes on Python 3.5-3.10 (as expected) # <_ast.Module object at 0x7f78d7b672e8> Example 2: =================================== import ast mylist = [] n = 1000000 print(ast.parse("mylist"+"+mylist"*n)) # <_ast.Module object at 0x7f78d7b672e8> =================================== The actual output: segmentation fault on Python 3.5 - 3.10 (not as expected) My system information: >> python3.10 -V Python 3.10.0a2 >> python3.9 -V Python 3.9.0rc1 >> python3.8 -V Python 3.8.0 >> python3.7 -V Python 3.7.3 >> python3.6 -V Python 3.6.12 >> uname -v #73~16.04.1-Ubuntu ---------- components: Interpreter Core messages: 383581 nosy: xxm priority: normal severity: normal status: open title: Segmentation fault in running ast.parse() with large expression size. type: crash versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42716> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com