summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-10-05 00:34:03 (GMT)
committerGitHub <noreply@github.com>2022-10-05 00:34:03 (GMT)
commit76449350b3467b85bcb565f9e2bf945bd150a66e (patch)
treee4237841cdb9d9984e3249823a8518c79470d73f /Include/cpython
parent0ff8fd65838f9f9ed90d7a055d26a2ce9fc0ce85 (diff)
downloadcpython-76449350b3467b85bcb565f9e2bf945bd150a66e.zip
cpython-76449350b3467b85bcb565f9e2bf945bd150a66e.tar.gz
cpython-76449350b3467b85bcb565f9e2bf945bd150a66e.tar.bz2
GH-91079: Decouple C stack overflow checks from Python recursion checks. (GH-96510)
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/pystate.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index cc3c3ea..7722a38 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -95,8 +95,10 @@ struct _ts {
/* Was this thread state statically allocated? */
int _static;
- int recursion_remaining;
- int recursion_limit;
+ int py_recursion_remaining;
+ int py_recursion_limit;
+
+ int c_recursion_remaining;
int recursion_headroom; /* Allow 50 more calls to handle any errors. */
/* 'tracing' keeps track of the execution depth when tracing/profiling.
@@ -202,6 +204,16 @@ struct _ts {
_PyCFrame root_cframe;
};
+/* WASI has limited call stack. Python's recursion limit depends on code
+ layout, optimization, and WASI runtime. Wasmtime can handle about 700
+ recursions, sometimes less. 500 is a more conservative limit. */
+#ifndef C_RECURSION_LIMIT
+# ifdef __wasi__
+# define C_RECURSION_LIMIT 500
+# else
+# define C_RECURSION_LIMIT 800
+# endif
+#endif
/* other API */