mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.13] gh-128717: Stop-the-world when setting the recursion limit (GH-128741) (#128757)
[3.13] gh-128717: Stop-the-world when setting the recursion limit (GH-128741)
(cherry picked from commit f6c61bf2d7
)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
f2a2809683
commit
1ec36a62eb
3 changed files with 36 additions and 0 deletions
|
@ -265,12 +265,16 @@ void
|
|||
Py_SetRecursionLimit(int new_limit)
|
||||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
_PyEval_StopTheWorld(interp);
|
||||
HEAD_LOCK(interp->runtime);
|
||||
interp->ceval.recursion_limit = new_limit;
|
||||
for (PyThreadState *p = interp->threads.head; p != NULL; p = p->next) {
|
||||
int depth = p->py_recursion_limit - p->py_recursion_remaining;
|
||||
p->py_recursion_limit = new_limit;
|
||||
p->py_recursion_remaining = new_limit - depth;
|
||||
}
|
||||
HEAD_UNLOCK(interp->runtime);
|
||||
_PyEval_StartTheWorld(interp);
|
||||
}
|
||||
|
||||
/* The function _Py_EnterRecursiveCallTstate() only calls _Py_CheckRecursiveCall()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue