Skip to content
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

Segmentation fault in running exec() with large expression size. #86881

Closed
xxm mannequin opened this issue Dec 22, 2020 · 2 comments
Closed

Segmentation fault in running exec() with large expression size. #86881

xxm mannequin opened this issue Dec 22, 2020 · 2 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@xxm
Copy link
Mannequin

xxm mannequin commented Dec 22, 2020

BPO 42715
Nosy @stestagg
Superseder
  • bpo-42712: Segmentation fault in running ast.literal_eval() with large expression size.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-12-26.01:41:01.525>
    created_at = <Date 2020-12-22.10:20:37.379>
    labels = ['interpreter-core', '3.8', '3.9', '3.10', '3.7', 'type-crash']
    title = 'Segmentation fault in running exec() with large expression size.'
    updated_at = <Date 2020-12-26.01:41:01.525>
    user = 'https://bugs.python.org/xxm'

    bugs.python.org fields:

    activity = <Date 2020-12-26.01:41:01.525>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-26.01:41:01.525>
    closer = 'terry.reedy'
    components = ['Interpreter Core']
    creation = <Date 2020-12-22.10:20:37.379>
    creator = 'xxm'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42715
    keywords = []
    message_count = 2.0
    messages = ['383580', '383604']
    nosy_count = 2.0
    nosy_names = ['xxm', 'stestagg']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '42712'
    type = 'crash'
    url = 'https://bugs.python.org/issue42715'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

    @xxm
    Copy link
    Mannequin Author

    xxm mannequin commented Dec 22, 2020

    Calling function exec() with large size can cause a segmentation fault in Python 3.7 -3.10. Please check the following two examples. The example 1 works as expected, while the second one triggers segmentation fault on Python 3.7,3.8,3.9,3.10. The primary difference between these two examples lay on the value of "n".

    Example 1:
    =========================================

    mylist = []
    n = 100000
    print(exec("mylist"+"+mylist"*n))

    ==========================================

    The actual output: Recursion Error on Python 3.5-3.10 (as expected)

    Example 2:
    ===================================

    mylist = []
    n = 1000000
    print(exec("mylist"+"+mylist"*n))

    ===================================

    The actual output: Recursive Error on Python 3.5, 3.6 (as expected), segmentation fault on Python 3.7, 3.8, 3.9, 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

    @xxm xxm mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Dec 22, 2020
    @stestagg
    Copy link
    Mannequin

    stestagg mannequin commented Dec 22, 2020

    As with the other issues, the underlying segfault is fixed in
    PR: #23744. It does however raise a RecursionError:

    RecursionError: maximum recursion depth exceeded during compilation

    As per https://bugs.python.org/issue42609#msg382910, Serhiy implies that the new recursion error is probably expected and acceptable.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant