aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-02-25 09:24:48 +0000
committerGitHub <noreply@github.com>2025-02-25 09:24:48 +0000
commit014223649c33b2febbccfa221c2ab7f18a8c0847 (patch)
tree5fb6432982ab3085d9275f20769f8fbcc581666b /Python/pystate.c
parent99088ab081279329b8362e1c24533fa0be303e6f (diff)
downloadcpython-014223649c33b2febbccfa221c2ab7f18a8c0847.tar.gz
cpython-014223649c33b2febbccfa221c2ab7f18a8c0847.zip
GH-130396: Use computed stack limits on linux (GH-130398)
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows * Remove calls to PyOS_CheckStack * Add stack protection to parser * Make tests more robust to low stacks * Improve error messages for stack overflow
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 24c7e290c50..09b83cdeb1f 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1490,10 +1490,9 @@ init_threadstate(_PyThreadStateImpl *_tstate,
// thread_id and native_thread_id are set in bind_tstate().
- tstate->py_recursion_limit = interp->ceval.recursion_limit,
- tstate->py_recursion_remaining = interp->ceval.recursion_limit,
- tstate->c_recursion_remaining = Py_C_RECURSION_LIMIT;
-
+ tstate->py_recursion_limit = interp->ceval.recursion_limit;
+ tstate->py_recursion_remaining = interp->ceval.recursion_limit;
+ tstate->c_recursion_remaining = 2;
tstate->exc_info = &tstate->exc_state;
// PyGILState_Release must not try to delete this thread state.
@@ -1508,6 +1507,10 @@ init_threadstate(_PyThreadStateImpl *_tstate,
tstate->previous_executor = NULL;
tstate->dict_global_version = 0;
+ _tstate->c_stack_soft_limit = UINTPTR_MAX;
+ _tstate->c_stack_top = 0;
+ _tstate->c_stack_hard_limit = 0;
+
_tstate->asyncio_running_loop = NULL;
_tstate->asyncio_running_task = NULL;