You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
recursive in finally clause cause Python interpreter crash. #86818
ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 12, in <module>
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10, in foo
foo()
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10, in foo
...
foo()
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10, in foo
foo()
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 7, in foo
traceback.print_exc()
File "/usr/lib/python3.5/traceback.py", line 159, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/usr/lib/python3.5/traceback.py", line 100, in print_exception
type(value), value, tb, limit=limit).format(chain=chain):
File "/usr/lib/python3.5/traceback.py", line 474, in __init__
capture_locals=capture_locals)
File "/usr/lib/python3.5/traceback.py", line 358, in extract
f.line
File "/usr/lib/python3.5/traceback.py", line 282, in line
self._line = linecache.getline(self.filename, self.lineno).strip()
File "/usr/lib/python3.5/linecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 43, in getlines
if len(entry) != 1:
RecursionError: maximum recursion depth exceeded in comparison
------------------------------------------------------------------------
However when moving foo() into finally clause, the interpreter crashes.
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 7, in foo
traceback.print_exc()
File "/usr/lib/python3.5/traceback.py", line 159, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/usr/lib/python3.5/traceback.py", line 100, in print_exceptiontype(value), value, tb, limit=limit).format(chain=chain):
File "/usr/lib/python3.5/traceback.py", line 474, in __init__
capture_locals=capture_locals)
File "/usr/lib/python3.5/traceback.py", line 358, in extract
f.line
File "/usr/lib/python3.5/traceback.py", line 282, in lineself._line = linecache.getline(self.filename, self.lineno).strip()
File "/usr/lib/python3.5/linecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 43, in getlinesiflen(entry) !=1:
RecursionError: maximum recursion depth exceeded in comparison
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo1/0
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
...
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
...
Aborted (core dumped)
-------------------------------------------------------------------------
=====
But it is still crash the interpreter in finally clause. I think this might be a new but and it is different from bpo-42500. It should be related to traceback module, finally clause and recursion. what do you think?
user@obsidian ~/t/f/cpython ((93a0ef76…))> git checkout 4e7a69bd^
HEAD is now at 93a0ef7647 Correct return type in Modules/_ssl.c::sslmodule_legacy (GH-23609)
+ make distclean
+ CFLAGS=-O0
+ ./configure --prefix=/home/user/prefix --exec-prefix=/home/user/prefix --cache-file=../config.cache --with-pydebug --without-ensurepip
+ CFLAGS=-O0
+ make -j8 install
/home/user/cpython/Lib/runpy.py:111: PendingDeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
__import__(pkg_name)
/home/user/cpython/Lib/runpy.py:111: PendingDeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
__import__(pkg_name)
++ realpath /home/user/prefix/include/python3.10d/
+ INCLUDE_DIR=/home/user/prefix/include/python3.10d
+ set +e
+ PYTHONHOME=/home/user/prefix
+ /home/user/prefix/bin/python3 ../test.py
Traceback (most recent call last):
File "/home/user/cpython/../test.py", line 5, in foo1/0ZeroDivisionError: division by zero
Traceback (most recent call last):
File "/home/user/cpython/../test.py", line 5, in foo1/0ZeroDivisionError: division by zero
...
File "/home/user/cpython/../test.py", line 10 in foo
File "/home/user/cpython/../test.py", line 10 in foo
...
../test.sh: line 33: 384713 Aborted (core dumped) PYTHONHOME=$PREFIX $EPREFIX/bin/python3 ../test.py
+ RESULT=134
+ [[ 134 -eq 139 ]]
+ [[ 134 -eq 134 ]]
+ exit 1
user@obsidian ~/t/f/cpython ((4e7a69bd…))> ../test.sh
+ make distclean
+ CFLAGS=-O0
+ ./configure --prefix=/home/user/prefix --exec-prefix=/home/user/prefix --cache-file=../config.cache --with-pydebug --without-ensurepip
+ CFLAGS=-O0
+ make -j8 install
/home/user/cpython/Lib/runpy.py:111: PendingDeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
__import__(pkg_name)
/home/user/cpython/Lib/runpy.py:111: PendingDeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
__import__(pkg_name)
+ /home/user/prefix/bin/python3 ../test.py
Traceback (most recent call last):
File "/home/user/cpython/../test.py", line 5, in foo1/0
...
File "/home/user/cpython/../test.py", line 10, in foo
foo()
File "/home/user/cpython/../test.py", line 10, in foo
foo()
[Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded
+ RESULT=1
+ [[ 1 -eq 139 ]]
+ [[ 1 -eq 134 ]]
+ exit 0
xxm commented on Dec 22, 2020
xxmmannequin
MannequinAuthor
More actions
Thanks for fixing this, looking forward to the new version.
Could you please kindly change the resolution into fixed and close this report?
Activity
xxm commentedon Dec 16, 2020
Considering the following two program,running the program 1 will get expected output: RecursionError
program 1
===========================
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10, in foo
foo()
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10, in foo
...
foo()
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10, in foo
foo()
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 7, in foo
traceback.print_exc()
File "/usr/lib/python3.5/traceback.py", line 159, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "/usr/lib/python3.5/traceback.py", line 100, in print_exception
type(value), value, tb, limit=limit).format(chain=chain):
File "/usr/lib/python3.5/traceback.py", line 474, in __init__
capture_locals=capture_locals)
File "/usr/lib/python3.5/traceback.py", line 358, in extract
f.line
File "/usr/lib/python3.5/traceback.py", line 282, in line
self._line = linecache.getline(self.filename, self.lineno).strip()
File "/usr/lib/python3.5/linecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "/usr/lib/python3.5/linecache.py", line 43, in getlines
if len(entry) != 1:
RecursionError: maximum recursion depth exceeded in comparison
------------------------------------------------------------------------
However when moving foo() into finally clause, the interpreter crashes.
program 2
==========================
==========================
-----------------------------------------------------------------------------
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
...
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 10 in foo
...
Aborted (core dumped)
-------------------------------------------------------------------------
ronaldoussoren commentedon Dec 17, 2020
This might be related to bpo-42500
xxm commentedon Dec 17, 2020
In issue bpo-42500, crashes is resulted by recursion and try-except. Program like following will crash the interpreter.
=====
=====
However with traceback module, program will no longer crash the interpreter. A recursive Error is returned as expected.
=====
=====
But it is still crash the interpreter in finally clause. I think this might be a new but and it is different from bpo-42500. It should be related to traceback module, finally clause and recursion. what do you think?
stestagg commentedon Dec 17, 2020
This was also fixed by bpo-42500, in commit 4e7a69b
===
====
user@obsidian ~/t/f/cpython ((93a0ef7…)) [1]> git checkout 4e7a69b
Previous HEAD position was 93a0ef7 Correct return type in Modules/_ssl.c::sslmodule_legacy (GH-23609)
HEAD is now at 4e7a69b bpo-42500: Fix recursion in or after except (GH-23568)
====
xxm commentedon Dec 22, 2020
Thanks for fixing this, looking forward to the new version.
Could you please kindly change the resolution into fixed and close this report?