Recursion Depth Exceeded Causes Crash
See original GitHub issueIn 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Maximum recursion error depth causing crash? - Stack Overflow
I would check your logic, hitting the recursion depth could mean you a not correctly terminating your recursion logic. – AChampion. Aug 24,...
Read more >Crash of my script maximum recursion depth exceeded : Forums
If you want something to run forever, restarting if it crashes for any reason, then the best place to set it up is...
Read more >Why does Mathematica crash at a certain recursion depth?
$RecursionLimit: Recursion depth of 70000 exceeded during evaluation of 1+x. But at $RecursionLimit = 80000 , Mathematica crashes (i.e. goes ...
Read more >Why does increasing the recursion limit to a number such as ...
The recursion limit is there specifically to avoid these types of crashes. Recursive functions have high memory requirements. Each recursion doubles the ...
Read more >Crash with RecursionError: maximum recursion depth exceeded
Control: retitle -1 britney: Crash with RecursionError: maximum recursion depth exceeded. On Fri, 2022-05-06 at 12:41 +0200, Christian Marillat wrote:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To make this more reproducible:
Changing the recursionlimit to be something like 1000 avoids the issue, though. I can recover from the maximum recursion error.
I can confirm this is affecting me as well, with Python 3.10.4 on Windows 11; it is also affecting JupyterLab, as one might expect.
Packages