mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
bpo-31857: Make the behavior of USE_STACKCHECK deterministic (#4098)
This commit is contained in:
parent
32318930da
commit
1896793520
6 changed files with 15 additions and 11 deletions
|
@ -469,13 +469,15 @@ _Py_CheckRecursiveCall(const char *where)
|
|||
int recursion_limit = _PyRuntime.ceval.recursion_limit;
|
||||
|
||||
#ifdef USE_STACKCHECK
|
||||
tstate->stackcheck_counter = 0;
|
||||
if (PyOS_CheckStack()) {
|
||||
--tstate->recursion_depth;
|
||||
PyErr_SetString(PyExc_MemoryError, "Stack overflow");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
/* Needed for ABI backwards-compatibility (see bpo-31857) */
|
||||
_Py_CheckRecursionLimit = recursion_limit;
|
||||
#endif
|
||||
if (tstate->recursion_critical)
|
||||
/* Somebody asked that we don't check for recursion. */
|
||||
return 0;
|
||||
|
|
|
@ -245,6 +245,7 @@ new_threadstate(PyInterpreterState *interp, int init)
|
|||
tstate->recursion_depth = 0;
|
||||
tstate->overflowed = 0;
|
||||
tstate->recursion_critical = 0;
|
||||
tstate->stackcheck_counter = 0;
|
||||
tstate->tracing = 0;
|
||||
tstate->use_tracing = 0;
|
||||
tstate->gilstate_counter = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue