classification
Title: Fatal Python error: Cannot recover from stack overflow.
Type: crash Stage:
Components: Interpreter Core Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Interpreter aborts when chaining an infinite number of exceptions
View: 6028
Assigned To: Nosy List: jcea, oscarbenjamin, pconnell, vstinner
Priority: normal Keywords:

Created on 2013-06-03 22:18 by oscarbenjamin, last changed 2013-10-04 03:56 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
crash.py oscarbenjamin, 2013-06-03 22:18
Messages (1)
msg190568 - (view) Author: Oscar Benjamin (oscarbenjamin) * Date: 2013-06-03 22:18
This is from a thread on python-list that started here:
http://mail.python.org/pipermail/python-list/2013-May/647895.html

There are situations in which the Python 3.2 and 3.3 interpreters crash with "Fatal Python error: Cannot recover from stack overflow."
when I believe the correct response is a RuntimeError (as happens in 2.7). I've attached a file crash.py that demonstrates the problem.

The following gives the same behaviour in 2.7, 3.2 and 3.3:

$ cat tmp.py
def loop():
    loop()

loop()

$ py -3.2 tmp.py
Traceback (most recent call last):
  File "tmp.py", line 4, in <module>
    loop()
  File "tmp.py", line 2, in loop
    loop()
  File "tmp.py", line 2, in loop
    loop()
  File "tmp.py", line 2, in loop
    loop()
  File "tmp.py", line 2, in loop
...

However the following leads to a RuntimeError in 2.7 but different
fatal stack overflow errors in 3.2 and 3.3 (tested on Windows XP using 32-bit python.org installers):

$ cat tmp.py
def loop():
    try:
        (lambda: None)()
    except RuntimeError:
        pass
    loop()

loop()

$ py -2.7 tmp.py
Traceback (most recent call last):
  File "tmp.py", line 8, in <module>
    loop()
  File "tmp.py", line 6, in loop
    loop()
  File "tmp.py", line 6, in loop
    loop()
  File "tmp.py", line 6, in loop
    loop()
  File "tmp.py", line 6, in loop
...
RuntimeError: maximum recursion depth exceeded

$ py -3.2 tmp.py
Fatal Python error: Cannot recover from stack overflow.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

$ py -3.3 tmp.py
Fatal Python error: Cannot recover from stack overflow.

Current thread 0x000005c4:
  File "tmp.py", line 3 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
...

Also tested on stock Python 3.2.3 on Ubuntu (2.7 gives RuntimeError):

$ python3 tmp.py 
Fatal Python error: Cannot recover from stack overflow.
Aborted (core dumped)


I would expect this to give "RuntimeError: maximum recursion depth
exceeded" in all cases.


Oscar
History
Date User Action Args
2013-10-04 03:56:36benjamin.petersonsetstatus: open -> closed
superseder: Interpreter aborts when chaining an infinite number of exceptions
resolution: duplicate
2013-10-04 02:23:31jceasetnosy: + jcea
2013-06-08 09:33:54pconnellsetnosy: + pconnell
2013-06-05 00:48:34vstinnersetnosy: + vstinner
2013-06-03 22:18:52oscarbenjamincreate