summaryrefslogtreecommitdiffstats
path: root/Include/ceval.h
diff options
context:
space:
mode:
authorpdox <pdox@alum.mit.edu>2017-10-26 06:03:01 (GMT)
committerBenjamin Peterson <benjamin@python.org>2017-10-26 06:03:01 (GMT)
commit1896793520a49a6f97ae360c0b288967e56b005e (patch)
treeb757b6b4691e52d5f3d22177ac23de50ad7d1d25 /Include/ceval.h
parent32318930da70ff03320ec50813b843e7db6fbc2e (diff)
downloadcpython-1896793520a49a6f97ae360c0b288967e56b005e.zip
cpython-1896793520a49a6f97ae360c0b288967e56b005e.tar.gz
cpython-1896793520a49a6f97ae360c0b288967e56b005e.tar.bz2
bpo-31857: Make the behavior of USE_STACKCHECK deterministic (#4098)
Diffstat (limited to 'Include/ceval.h')
-rw-r--r--Include/ceval.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/Include/ceval.h b/Include/ceval.h
index c5ccf47..70306b8 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -93,21 +93,19 @@ PyAPI_FUNC(int) Py_GetRecursionLimit(void);
PyThreadState_GET()->overflowed = 0; \
} while(0)
PyAPI_FUNC(int) _Py_CheckRecursiveCall(const char *where);
-/* XXX _Py_CheckRecursionLimit should be changed to
- _PyRuntime.ceval.check_recursion_limit. However, due to the macros
- in which it's used, _Py_CheckRecursionLimit is stuck in the stable
- ABI. It should be removed therefrom when possible.
+
+/* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
+ the stable ABI. It should be removed therefrom when possible.
*/
PyAPI_DATA(int) _Py_CheckRecursionLimit;
#ifdef USE_STACKCHECK
-/* With USE_STACKCHECK, we artificially decrement the recursion limit in order
- to trigger regular stack checks in _Py_CheckRecursiveCall(), except if
- the "overflowed" flag is set, in which case we need the true value
- of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly.
+/* With USE_STACKCHECK, trigger stack checks in _Py_CheckRecursiveCall()
+ on every 64th call to Py_EnterRecursiveCall.
*/
# define _Py_MakeRecCheck(x) \
- (++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1))
+ (++(x) > _Py_CheckRecursionLimit || \
+ ++(PyThreadState_GET()->stackcheck_counter) > 64)
#else
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
#endif