gh-128717: Stop-the-world when setting the recursion limit (#128741)

This commit is contained in:
Peter Bierma 2025-01-12 08:04:30 -05:00 committed by GitHub
parent ff39e3ff7b
commit f6c61bf2d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View file

@ -294,6 +294,7 @@ void
Py_SetRecursionLimit(int new_limit)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
_PyEval_StopTheWorld(interp);
interp->ceval.recursion_limit = new_limit;
_Py_FOR_EACH_TSTATE_BEGIN(interp, p) {
int depth = p->py_recursion_limit - p->py_recursion_remaining;
@ -301,6 +302,7 @@ Py_SetRecursionLimit(int new_limit)
p->py_recursion_remaining = new_limit - depth;
}
_Py_FOR_EACH_TSTATE_END(interp);
_PyEval_StartTheWorld(interp);
}
/* The function _Py_EnterRecursiveCallTstate() only calls _Py_CheckRecursiveCall()