This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Generator functions stack overflow
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, brett.cannon, xtreak
Priority: normal Keywords:

Created on 2018-11-29 18:40 by asdwqii, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
crash.py asdwqii, 2018-11-29 18:40
Messages (6)
msg330710 - (view) Author: - (asdwqii) Date: 2018-11-29 18:40
Gоt `Fatal Python error: Cannot recover from stack overflow.` on Windows 10, not tested on other os. Crashed when use undefined variable.
msg330712 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-11-29 19:02
I think I have seen this bug reported elsewhere but can't find it now.

A simple reproducer : 

def foo():
    try:
        raise Exception()
    except:
        foo()
foo()

Running under gdb on Ubuntu : 

Program received signal SIGABRT, Aborted.
0x00007ffff7115428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
msg330755 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-11-30 07:21
> I think I have seen this bug reported elsewhere but can't find it now.

Sorry, I was referring to issue6028 and issue32570 that I thought were similar to the original report.
msg330824 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-11-30 20:07
How did you make a recursive generator? The 'yield' would have paused execution. Do you have code you can share to reproduce? Otherwise blowing your stack out is normal behaviour in a function which you can deal with by lowering your stack depth with sys.setrecursionlimit() to one that will raise RecursionError before you blow your stack.
msg330840 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-12-01 03:41
Brett, the user had an invalid email address in their profile thus adding comments to the issue caused a server error while sending notification to them. So they have been removed from the issue. Please see : https://python.zulipchat.com/#narrow/stream/116501-workflow/subject/Is.20adding.20comment.20in.20bpo.20broken.20for.20anyone.3F/near/148846056

As for the issue OP attached a reproducer where they produce NameError with the "new" variable which is not defined in the try block and catch the exception to make recursive calls in https://bugs.python.org/file47958/crash.py
msg341739 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2019-05-07 14:47
I'm closing this as a duplicate of https://bugs.python.org/issue6028

Making a recursive call in an except block cannot be handled sensibly by the interpreter. 

On exceeding the stack depth, the interpreter will raise a RecursionError.
Catching a RecursionError and then making a call will blow the stack, leaving the interpreter with no choice; it has to abort.
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79535
2019-05-07 14:47:40Mark.Shannonsetstatus: open -> closed

nosy: + Mark.Shannon
messages: + msg341739

resolution: duplicate
stage: resolved
2018-12-01 03:41:01xtreaksetmessages: + msg330840
2018-11-30 20:07:27brett.cannonsetnosy: + brett.cannon
messages: + msg330824
2018-11-30 07:21:07xtreaksetmessages: + msg330755
2018-11-30 07:20:18ezio.melottisetnosy: - asdwqii
2018-11-29 19:02:35xtreaksetnosy: + xtreak

messages: + msg330712
versions: + Python 3.8
2018-11-29 18:40:29asdwqiicreate