[New-bugs-announce] [issue42951] Random and infinite loop in dealing with recursion error for "try-except "

Xinmeng Xia report at bugs.python.org
Sun Jan 17 23:17:00 EST 2021


New submission from Xinmeng Xia <xiaxm at smail.nju.edu.cn>:

In issue 42500, recursive calls in "Try-except" are resolved. This PR has fixed the crashes of some programs, such as program 1. And the core dump error is replaced with RecursiveError.  
However, program 2 will not report a RecursiveError. The program will fall into an infinite loop. Even "Ctrl C" cannot stop the infinite loop. I try to track the execution of this program and insert "print" information(see program 3). The output seems random in execution between try branch and except branch!  I think this is a new bug after fixing 42500. I believe the program should also return RecursiveError.


Program 1
=========================== 
def foo():
    try:
        1/0
    except:
        foo()
foo()
================================

Program 2
================================
def foo():
    try:
        foo()
    except:
        foo()
foo()
================================


Program 3
================================
def foo():
    try:
        print("a")
        foo()
    except:
        print("b")
        foo()

foo()
================================
Output for program3( unexpected infinite random loop. ):
......bbaaaabbabbaabbabbaaabbabbaabbabbaaaaaaaabbabbaabbabbaaabbabbaabbabbaaaabbabbaabbabbaaabbabbaabbabbaaaaabbabbaabbabbaaabbabbaabbabbaaaabbabbaabbabbaaabbabbaabbabbaaaaaabbabbaabbabbaaabbabbaabbabbaaaabb......

>>python -V
Python 3.10.0a4

----------
components: Interpreter Core
messages: 385171
nosy: xxm
priority: normal
severity: normal
status: open
title: Random and infinite loop in dealing with recursion error for "try-except "
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42951>
_______________________________________


More information about the New-bugs-announce mailing list