Skip to content

ast.literal_eval Segmentation Fault in Python 3.10 #126710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EgodPrime opened this issue Nov 12, 2024 · 3 comments
Closed

ast.literal_eval Segmentation Fault in Python 3.10 #126710

EgodPrime opened this issue Nov 12, 2024 · 3 comments
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@EgodPrime
Copy link

EgodPrime commented Nov 12, 2024

Crash report

What happened?

a = 'P/a'*200000
import ast
ast.literal_eval(a)

The above code makes Python 3.10 crash with Segmentation Fault.

CPython versions tested on:

3.9, 3.10

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.10.15 (main, Oct 3 2024, 07:27:34) [GCC 11.2.0]

@EgodPrime EgodPrime added the type-crash A hard crash of the interpreter, possibly with a core dump label Nov 12, 2024
@skirpichev skirpichev added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Nov 12, 2024
@skirpichev
Copy link
Member

BTW, in 3.11+ we have:

>>> a = 'P/a'*200000
>>> import ast
>>> ast.literal_eval(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded during ast construction

@EgodPrime
Copy link
Author

Sorry, this issue is a mistake commit, I have made a new one

@zware
Copy link
Member

zware commented Nov 12, 2024

For future reference, there was no need to create a new issue, this one could easily have been updated. I very nearly closed the new one as a duplicate before catching up here.

Duplicate of gh-126711.

@zware zware closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
@picnixz picnixz removed needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

4 participants