Skip to content

RecursionError with hundreds of consecutive function calls #2525

Open
@correctmost

Description

@correctmost

Steps to reproduce

The following code triggers a RecursionError in astroid:

a()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()

This bug was discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64104 (report not public yet)

Current behavior

Exception on node <Call l.1 at 0x77b464c1d5b0> in file 'corpus/a.py'
Traceback (most recent call last):
  File "pylint/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "pylint/pylint/checkers/refactoring/refactoring_checker.py", line 1161, in visit_call
    self._check_use_list_literal(node)
  File "pylint/pylint/checkers/refactoring/refactoring_checker.py", line 1712, in _check_use_list_literal
    if node.as_string() == "list()":
       ^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 619, in as_string
    return AsStringVisitor()(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/as_string.py", line 47, in __call__
    return node.accept(self).replace(DOC_NEWLINE, "\n")
           ^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 238, in accept
    return func(self)
           ^^^^^^^^^^

[...snip...]

  File "astroid/astroid/nodes/as_string.py", line 164, in visit_call
    expr_str = self._precedence_parens(node, node.func)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/as_string.py", line 73, in _precedence_parens
    return child.accept(self)
           ^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/node_ng.py", line 238, in accept
    return func(self)
           ^^^^^^^^^^
  File "astroid/astroid/nodes/as_string.py", line 164, in visit_call
    expr_str = self._precedence_parens(node, node.func)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/as_string.py", line 70, in _precedence_parens
    if self._should_wrap(node, child, is_left):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "astroid/astroid/nodes/as_string.py", line 80, in _should_wrap
    node_precedence = node.op_precedence()
                      ^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

Expected behavior

No crash

Version

d8dbc46

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions