summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-06-27 16:33:01 (GMT)
committerGitHub <noreply@github.com>2022-06-27 16:33:01 (GMT)
commit56f5f904968b3796dad942e87e971e7b87c571f3 (patch)
treeec2376fd8dd2d1b928e29b0922a362152f952a41
parent4ec146cefd2446f7e19e05091949c84836223b59 (diff)
downloadcpython-56f5f904968b3796dad942e87e971e7b87c571f3.zip
cpython-56f5f904968b3796dad942e87e971e7b87c571f3.tar.gz
cpython-56f5f904968b3796dad942e87e971e7b87c571f3.tar.bz2
[3.11] gh-90473: Reduce recursion limit on WASI even further (GH-94333) (GH-94334)
Co-authored-by: Christian Heimes <christian@python.org>
-rw-r--r--Include/internal/pycore_ceval.h7
-rw-r--r--Lib/test/test_tomllib/test_misc.py4
2 files changed, 6 insertions, 5 deletions
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index d969a5e..8d18d20 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -12,11 +12,12 @@ extern "C" {
struct pyruntimestate;
struct _ceval_runtime_state;
-/* WASI has limited call stack. wasmtime 0.36 can handle sufficient amount of
- C stack frames for little more than 750 recursions. */
+/* WASI has limited call stack. Python's recursion limit depends on code
+ layout, optimization, and WASI runtime. Wasmtime can handle about 700-750
+ recursions, sometimes less. 600 is a more conservative limit. */
#ifndef Py_DEFAULT_RECURSION_LIMIT
# ifdef __wasi__
-# define Py_DEFAULT_RECURSION_LIMIT 750
+# define Py_DEFAULT_RECURSION_LIMIT 600
# else
# define Py_DEFAULT_RECURSION_LIMIT 1000
# endif
diff --git a/Lib/test/test_tomllib/test_misc.py b/Lib/test/test_tomllib/test_misc.py
index 378db58..a477a21 100644
--- a/Lib/test/test_tomllib/test_misc.py
+++ b/Lib/test/test_tomllib/test_misc.py
@@ -92,8 +92,8 @@ class TestMiscellaneous(unittest.TestCase):
self.assertEqual(obj_copy, expected_obj)
def test_inline_array_recursion_limit(self):
- # 470 with default recursion limit
- nest_count = int(sys.getrecursionlimit() * 0.47)
+ # 465 with default recursion limit
+ nest_count = int(sys.getrecursionlimit() * 0.465)
recursive_array_toml = "arr = " + nest_count * "[" + nest_count * "]"
tomllib.loads(recursive_array_toml)