[New-bugs-announce] [issue18129] Fatal Python error: Cannot recover from stack overflow.

Oscar Benjamin report at bugs.python.org
Tue Jun 4 00:18:52 CEST 2013


New submission from Oscar Benjamin:

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

----------
components: Interpreter Core
files: crash.py
messages: 190568
nosy: oscarbenjamin
priority: normal
severity: normal
status: open
title: Fatal Python error: Cannot recover from stack overflow.
type: crash
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file30458/crash.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18129>
_______________________________________


More information about the New-bugs-announce mailing list