[Python-checkins] gh-90473: Reduce recursion limit on WASI even further (GH-94333)

tiran webhook-mailer at python.org
Mon Jun 27 10:19:58 EDT 2022


https://github.com/python/cpython/commit/e5e51556e45ff70053b8a7f90a07ded966401911
commit: e5e51556e45ff70053b8a7f90a07ded966401911
branch: main
author: Christian Heimes <christian at python.org>
committer: tiran <christian at python.org>
date: 2022-06-27T16:19:47+02:00
summary:

gh-90473: Reduce recursion limit on WASI even further (GH-94333)

750 fails sometimes with newer wasmtime versions. 600 is a more
conservative value.

files:
M Include/internal/pycore_ceval.h
M Lib/test/test_tomllib/test_misc.py

diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index dafe31b216bf0..1b999301938c5 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 378db58f25594..a477a219fd9eb 100644
--- a/Lib/test/test_tomllib/test_misc.py
+++ b/Lib/test/test_tomllib/test_misc.py
@@ -92,8 +92,8 @@ def test_deepcopy(self):
         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)
 



More information about the Python-checkins mailing list