]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-90473: Reduce recursion limit on WASI even further (GH-94333) (GH-94334)
authorChristian Heimes <christian@python.org>
Mon, 27 Jun 2022 16:33:01 +0000 (18:33 +0200)
committerGitHub <noreply@github.com>
Mon, 27 Jun 2022 16:33:01 +0000 (18:33 +0200)
Co-authored-by: Christian Heimes <christian@python.org>
Include/internal/pycore_ceval.h
Lib/test/test_tomllib/test_misc.py

index d969a5e6eb99bbd96fbeef5bb34685c91bff375d..8d18d200aa4bf06c1209b2b8557ff11f98af3c79 100644 (file)
@@ -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
index 378db58f255945ec16823ed6ee5577da7cf8706a..a477a219fd9ebd68e80c491295a78671a6d97df3 100644 (file)
@@ -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)