Fatal Python error

Oscar Benjamin oscar.j.benjamin at gmail.com
Wed May 29 11:17:58 EDT 2013


On 29 May 2013 14:02, Dave Angel <davea at davea.name> wrote:
> On 05/29/2013 08:45 AM, Oscar Benjamin wrote:
>
> More likely a bug in the 2.x interpreter.  Once inside an exception handler,
> that frame must be held somehow.  If not on the stack, then in some separate
> list.  So the logic will presumably fill memory, it just may take longer on
> 2.x .

I'm not so sure. 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
stack overflow errors in 3.2 and 3.3:

$ 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
...

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


Oscar



More information about the Python-list mailing list