@@ -93,21 +93,19 @@ PyAPI_FUNC(int) Py_GetRecursionLimit(void);
9393 PyThreadState_GET()->overflowed = 0; \
9494 } while(0)
9595PyAPI_FUNC (int ) _Py_CheckRecursiveCall (const char * where );
96- /* XXX _Py_CheckRecursionLimit should be changed to
97- _PyRuntime.ceval.check_recursion_limit. However, due to the macros
98- in which it's used, _Py_CheckRecursionLimit is stuck in the stable
99- ABI. It should be removed therefrom when possible.
96+
97+ /* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
98+ the stable ABI. It should be removed therefrom when possible.
10099*/
101100PyAPI_DATA (int ) _Py_CheckRecursionLimit ;
102101
103102#ifdef USE_STACKCHECK
104- /* With USE_STACKCHECK, we artificially decrement the recursion limit in order
105- to trigger regular stack checks in _Py_CheckRecursiveCall(), except if
106- the "overflowed" flag is set, in which case we need the true value
107- of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly.
103+ /* With USE_STACKCHECK, trigger stack checks in _Py_CheckRecursiveCall()
104+ on every 64th call to Py_EnterRecursiveCall.
108105*/
109106# define _Py_MakeRecCheck (x ) \
110- (++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1))
107+ (++(x) > _Py_CheckRecursionLimit || \
108+ ++(PyThreadState_GET()->stackcheck_counter) > 64)
111109#else
112110# define _Py_MakeRecCheck (x ) (++(x) > _Py_CheckRecursionLimit)
113111#endif
0 commit comments