diff options
author | 2020-12-02 13:30:55 +0000 | |
---|---|---|
committer | 2020-12-02 13:30:55 +0000 | |
commit | 4e7a69bdb63a104587759d7784124492dcdd496e (patch) | |
tree | 5477c7077970d9100d089286b75ce2ff408ac613 /Include | |
parent | Correct return type in Modules/_ssl.c::sslmodule_legacy (GH-23609) (diff) | |
download | cpython-4e7a69bdb63a104587759d7784124492dcdd496e.tar.gz cpython-4e7a69bdb63a104587759d7784124492dcdd496e.tar.bz2 cpython-4e7a69bdb63a104587759d7784124492dcdd496e.zip |
bpo-42500: Fix recursion in or after except (GH-23568)
* Use counter, rather boolean state when handling soft overflows.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/pystate.h | 3 | ||||
-rw-r--r-- | Include/internal/pycore_ceval.h | 16 |
2 files changed, 1 insertions, 18 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h index 0e6cc290912..cfaee890f97 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/pystate.h @@ -54,8 +54,7 @@ struct _ts { /* Borrowed reference to the current frame (it can be NULL) */ PyFrameObject *frame; int recursion_depth; - char overflowed; /* The stack has overflowed. Allow 50 more calls - to handle the runtime error. */ + int recursion_headroom; /* Allow 50 more calls to handle any errors. */ int stackcheck_counter; /* 'tracing' keeps track of the execution depth when tracing/profiling. diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index bbb667ea32d..38fd681f20c 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -92,24 +92,8 @@ static inline int _Py_EnterRecursiveCall_inline(const char *where) { #define Py_EnterRecursiveCall(where) _Py_EnterRecursiveCall_inline(where) -/* Compute the "lower-water mark" for a recursion limit. When - * Py_LeaveRecursiveCall() is called with a recursion depth below this mark, - * the overflowed flag is reset to 0. */ -static inline int _Py_RecursionLimitLowerWaterMark(int limit) { - if (limit > 200) { - return (limit - 50); - } - else { - return (3 * (limit >> 2)); - } -} - static inline void _Py_LeaveRecursiveCall(PyThreadState *tstate) { tstate->recursion_depth--; - int limit = tstate->interp->ceval.recursion_limit; - if (tstate->recursion_depth < _Py_RecursionLimitLowerWaterMark(limit)) { - tstate->overflowed = 0; - } } static inline void _Py_LeaveRecursiveCall_inline(void) { |