Skip to content

Recursion Depth Exceeded Causes Crash #12197

@Veemon

Description

@Veemon

In IDLE:

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class Vec2:
...     def __init__(self, x=0.0, y=0.0):
...             self.x = x
...             self.y = y
...     def __mul__(self, other):
...             if type(other) is not Vec2:
...                     result = Vec2()
...                     result.x = self.x * other
...                     result.y = self.y * other
...                     return result
...             else:
...                     return self.x*other.x + self.y*other.y
...     def __rmul__(self, other):
...             # introduce bug where self and other should be swapped
...             return other * self
...
>>> x = Vec2(1.0, 1.0)
>>> x * 2
<__main__.Vec2 object at 0x0000016278FA7100>
>>> 2 * x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 15, in __rmul__
  File "<stdin>", line 15, in __rmul__
  File "<stdin>", line 15, in __rmul__
  [Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded

Running in iPython, instead of a RecursionError, the program directly crashes.
After the crash, the ERRORLEVEL flag is set to -1073741571.
On pip 19.2.3, these are the following dependencies,

Package          Version
---------------- -------
backcall         0.1.0
colorama         0.4.3
cycler           0.10.0
decorator        4.4.2
ipython          7.13.0
ipython-genutils 0.2.0
jedi             0.16.0
kiwisolver       1.1.0
matplotlib       3.2.1
numpy            1.18.2
parso            0.6.2
pickleshare      0.7.5
pip              19.2.3
prompt-toolkit   3.0.4
Pygments         2.6.1
pyparsing        2.4.6
python-dateutil  2.8.1
setuptools       41.2.0
six              1.14.0
traitlets        4.3.3
wcwidth          0.1.8

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