Message382112
This might be the expected behavior. See https://bugs.python.org/issue25222
If you already caught a RecursionError and you keep recursing anyway, once you go 50 levels beyond sys.getrecursionlimit(), the interpreter crashes regardless of what is `except`ed. In /Python/ceval.c, there's this:
if (tstate->overflowed) {
if (tstate->recursion_depth > recursion_limit + 50) {
/* Overflowing while handling an overflow. Give up. */
Py_FatalError("Cannot recover from stack overflow.");
}
return 0;
}
In your Program 2, when the interpreter raises a `RecursionError`, it is raised normally and everything is fine.
In your Program 1, when the interpreter raises a `RecursionError`, it is `except`ed, so the interpreter thinks it's okay to keep going, and when it does, it raises more `RecursionError`s, which it keeps `except`ing, until it finally can't go any farther ( > 50 + sys.getrecursionlimit()), and has no option but to crash.
"Cannot recover from stack overflow." seems to make sense to me: when the interpreter tries to recover, the code won't let it. |
|
Date |
User |
Action |
Args |
2020-11-30 06:51:27 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, xxm |
2020-11-30 06:51:27 | Dennis Sweeney | set | messageid: <1606719087.2.0.953559907215.issue42509@roundup.psfhosted.org> |
2020-11-30 06:51:27 | Dennis Sweeney | link | issue42509 messages |
2020-11-30 06:51:26 | Dennis Sweeney | create | |
|