RecursionError with hundreds of consecutive unary operators
correctmost opened this issue · 0 comments
correctmost commented
Steps to reproduce
The following code triggers a RecursionError
in astroid:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0
This bug was discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=57943 (report not public yet)
Current behavior
Traceback (most recent call last):
File "pylint/pylint/lint/pylinter.py", line 786, in _lint_file
check_astroid_module(module)
File "pylint/pylint/lint/pylinter.py", line 1015, in check_astroid_module
retval = self._check_astroid_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pylint/pylint/lint/pylinter.py", line 1063, in _check_astroid_module
raw_checker.process_module(node)
File "pylint/pylint/checkers/symilar.py", line 841, in process_module
self.append_stream(self.linter.current_name, stream, node.file_encoding)
File "pylint/pylint/checkers/symilar.py", line 377, in append_stream
LineSet(
File "pylint/pylint/checkers/symilar.py", line 682, in __init__
self._stripped_lines = stripped_lines(
^^^^^^^^^^^^^^^
File "pylint/pylint/checkers/symilar.py", line 590, in stripped_lines
tree = astroid.parse("".join(lines))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/builder.py", line 300, in parse
return builder.string_build(code, modname=module_name, path=path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/builder.py", line 151, in string_build
module, builder = self._data_build(data, modname, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/builder.py", line 206, in _data_build
module = builder.visit_module(node, modname, node_file, package)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 171, in visit_module
[self.visit(child, newnode) for child in node.body],
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 448, in visit
return visit_method(node, parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 972, in visit_expr
newnode.postinit(self.visit(node.value, newnode))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 448, in visit
return visit_method(node, parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 1637, in visit_unaryop
newnode.postinit(self.visit(node.operand, newnode))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 448, in visit
return visit_method(node, parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 1637, in visit_unaryop
newnode.postinit(self.visit(node.operand, newnode))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 448, in visit
return visit_method(node, parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 1637, in visit_unaryop
newnode.postinit(self.visit(node.operand, newnode))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...snip...]
File "astroid/astroid/rebuilder.py", line 448, in visit
return visit_method(node, parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 1637, in visit_unaryop
newnode.postinit(self.visit(node.operand, newnode))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 448, in visit
return visit_method(node, parent)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "astroid/astroid/rebuilder.py", line 1395, in visit_constant
return nodes.Const(
^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "pylint/pylint/lint/pylinter.py", line 750, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "pylint/pylint/lint/pylinter.py", line 788, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
No crash