This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xxm
Recipients xxm
Date 2020-12-22.10:17:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608632245.06.0.0184110305677.issue42712@roundup.psfhosted.org>
In-reply-to
Content
Calling function ast.literal_eval() 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.literal_eval("mylist"+"+mylist"*n))
==========================================

The actual output: value Error on Python 3.5,3.7,3.8,3.9,3.10, Recursive Error on Python 3.6 (as expected)



Example 2:
===================================
import ast
mylist = []
n = 1000000
print(ast.literal_eval("mylist"+"+mylist"*n))
===================================

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
History
Date User Action Args
2020-12-22 10:17:25xxmsetrecipients: + xxm
2020-12-22 10:17:25xxmsetmessageid: <1608632245.06.0.0184110305677.issue42712@roundup.psfhosted.org>
2020-12-22 10:17:25xxmlinkissue42712 messages
2020-12-22 10:17:24xxmcreate