Skip to content

A long string in ast.parse() leads to a segfault #4857

Closed

Description

@xiaxinmeng

ast.parse() takes a long string as the argument leading to a segfault.

test.py

import ast
x = ast.parse('+chr(33)'*1000000)

Crash message: Segmentation fault (core dumped)

Environment:
Ubuntu 18.04
rustpython v0.2.0

Activity

  1. DimitrisJim commented on Apr 6, 2023

    @DimitrisJim
    Member

    Nice, this seems like a variation of #4862. Basically we're creating a deeply nested AST here since the rhs of every BinOp will be another BinOp so it fails while trying to recurse into this.

    Both these issues will most likely be solved by the same solution: checks while recursing deeply during the compilation phase (I'm guessing the AST traversal is the cause here but I'd need to check to make sure).

    Thanks a lot for reporting and feel free to re-open if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions