summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-08-04 10:25:51 (GMT)
committerGitHub <noreply@github.com>2023-08-04 10:25:51 (GMT)
commit98902d6c0522df022d2f88499faf9774970e2838 (patch)
tree3c5919fae5314286a774ae9ebe8e682a4b5d50c5 /Python/ceval.c
parent58af2293c52a1ad3754d254690c0e54f787c545b (diff)
downloadcpython-98902d6c0522df022d2f88499faf9774970e2838.zip
cpython-98902d6c0522df022d2f88499faf9774970e2838.tar.gz
cpython-98902d6c0522df022d2f88499faf9774970e2838.tar.bz2
[3.12] GH-107263: Increase C stack limit for most functions, except `_PyEval_EvalFrameDefault()` (GH-107535) (#107618)
GH-107263: Increase C stack limit for most functions, except `_PyEval_EvalFrameDefault()` (GH-107535) * Set C recursion limit to 1500, set cost of eval loop to 2 frames, and compiler mutliply to 2. (cherry picked from commit fa45958450aa3489607daf9855ca0474a2a20878) Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 4947420..88d6362 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -637,6 +637,11 @@ static inline void _Py_LeaveRecursiveCallPy(PyThreadState *tstate) {
# pragma warning(disable:4102)
#endif
+
+/* _PyEval_EvalFrameDefault() is a *big* function,
+ * so consume 3 units of C stack */
+#define PY_EVAL_C_STACK_UNITS 2
+
PyObject* _Py_HOT_FUNCTION
_PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
{
@@ -691,6 +696,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
frame->previous = &entry_frame;
cframe.current_frame = frame;
+ tstate->c_recursion_remaining -= (PY_EVAL_C_STACK_UNITS - 1);
if (_Py_EnterRecursiveCallTstate(tstate, "")) {
tstate->c_recursion_remaining--;
tstate->py_recursion_remaining--;
@@ -990,7 +996,7 @@ exit_unwind:
/* Restore previous cframe and exit */
tstate->cframe = cframe.previous;
assert(tstate->cframe->current_frame == frame->previous);
- _Py_LeaveRecursiveCallTstate(tstate);
+ tstate->c_recursion_remaining += PY_EVAL_C_STACK_UNITS;
return NULL;
}