[issue42652] recursive in finally clause cause Python interpreter crash.

2020-12-22 Thread Ronald Oussoren


Change by Ronald Oussoren :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
superseder:  -> crash with unbounded recursion in except statement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42652] recursive in finally clause cause Python interpreter crash.

2020-12-22 Thread Xinmeng Xia


Xinmeng Xia  added the comment:

Thanks for fixing this, looking forward to the new version.

Could you please kindly change the resolution into fixed and close this report?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42652] recursive in finally clause cause Python interpreter crash.

2020-12-17 Thread Steve Stagg

Steve Stagg  added the comment:

This was also fixed by bpo-42500, in commit 4e7a69bdb6 
===
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 foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/user/cpython/../test.py", line 5, in foo
1/0
ZeroDivisionError: 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 ((93a0ef76…)) [1]> git checkout 4e7a69bd
Previous HEAD position was 93a0ef7647 Correct return type in 
Modules/_ssl.c::sslmodule_legacy (GH-23609)
HEAD is now at 4e7a69bdb6 bpo-42500: Fix recursion in or after except (GH-23568)

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 foo
1/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

--
nosy: +stestagg

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42652] recursive in finally clause cause Python interpreter crash.

2020-12-17 Thread Xinmeng Xia


Xinmeng Xia  added the comment:

In issue #42500, crashes is resulted by recursion and try-except. Program like 
following will crash the interpreter.
=
def foo():
try:
1/0
except:
pass
foo()
foo()
=
However with traceback module, program will no longer crash the interpreter. A 
recursive Error is returned as expected. 
=
import traceback
def foo():
try:
1/0
except:
traceback.print_exc()
foo()
foo()
=
But it is still crash the interpreter in finally clause. I think this might be 
a new but and it is different from #42500. It should be related to traceback 
module, finally clause and recursion. what do you think?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42652] recursive in finally clause cause Python interpreter crash.

2020-12-17 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

This might be related to #42500

--
nosy: +ronaldoussoren

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42652] recursive in finally clause cause Python interpreter crash.

2020-12-16 Thread Xinmeng Xia


New submission from Xinmeng Xia :

Considering the following two program,running the program 1 will get expected 
output: RecursionError 

program 1
===
import traceback

def foo():
try:
1/0
except Exception as e:
traceback.print_exc()
finally:
a = 1
foo()   

foo()

==
---
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: 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 foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: 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 

  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
==
import traceback

def foo():
try:
1/0
except Exception as e:
traceback.print_exc()
finally:
a = 1
foo()   

foo()

==  
-
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 foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/xxm/Desktop/nameChanging/myerror/test1.py", line 5, in foo
1/0
ZeroDivisionError: 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_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

During