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.

Author thyyyy
Recipients thyyyy
Date 2020-07-17.03:41:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594957263.52.0.457195944754.issue41318@roundup.psfhosted.org>
In-reply-to
Content
Is it possible to add more detailed message for the error "Cannot recover from stack overflow"?
Something like "Cannot recover from stack overflow, it may be caused by catching a RecursionError but reaching the limit again before properly handling it."
Maybe the detailed design in https://github.com/python/cpython/blob/master/Include/ceval.h#L48 could also be shown to the developer?

It is hard to understand what happened only with the message "Cannot recover from stack overflow".

I hit the error because I write the code as following:
@some_logger
def f():
    return f()
try:
  f()
except RecursionError:
  print("Recursion Error is raised!")

And it took me a lot of time to figure out why RecursionError is not raised but the "Fatal Python error" is shown.
Finally I realized that the problem is that the following code piece in "some_logger" (Which is an internal library provided by others) caught the exception and make tstate->overflowed=1.

def some_logger(func):
    @functools.wraps(func)
    def new_func(*args, **kwargs):
        try:
            # Unfortunately this code hit RecursionError and catched it
            logger.info(some_message)
        except Exception as e:
            pass # Avoid affecting user function
        return func(*args, **kwargs)
    return new_func

So I think it might be better to provide more information to the developer that "Cannot recover" means that "RecursionError is caught and stack overflow again." and hint user to know the design of _Py_EnterRecursiveCall.
History
Date User Action Args
2020-07-17 03:41:03thyyyysetrecipients: + thyyyy
2020-07-17 03:41:03thyyyysetmessageid: <1594957263.52.0.457195944754.issue41318@roundup.psfhosted.org>
2020-07-17 03:41:03thyyyylinkissue41318 messages
2020-07-17 03:41:03thyyyycreate