Skip to content

Commit e5e5155

Browse files
authored
gh-90473: Reduce recursion limit on WASI even further (GH-94333)
750 fails sometimes with newer wasmtime versions. 600 is a more conservative value.
1 parent c0453a4 commit e5e5155

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Include/internal/pycore_ceval.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ extern "C" {
1212
struct pyruntimestate;
1313
struct _ceval_runtime_state;
1414

15-
/* WASI has limited call stack. wasmtime 0.36 can handle sufficient amount of
16-
C stack frames for little more than 750 recursions. */
15+
/* WASI has limited call stack. Python's recursion limit depends on code
16+
layout, optimization, and WASI runtime. Wasmtime can handle about 700-750
17+
recursions, sometimes less. 600 is a more conservative limit. */
1718
#ifndef Py_DEFAULT_RECURSION_LIMIT
1819
# ifdef __wasi__
19-
# define Py_DEFAULT_RECURSION_LIMIT 750
20+
# define Py_DEFAULT_RECURSION_LIMIT 600
2021
# else
2122
# define Py_DEFAULT_RECURSION_LIMIT 1000
2223
# endif

Lib/test/test_tomllib/test_misc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def test_deepcopy(self):
9292
self.assertEqual(obj_copy, expected_obj)
9393

9494
def test_inline_array_recursion_limit(self):
95-
# 470 with default recursion limit
96-
nest_count = int(sys.getrecursionlimit() * 0.47)
95+
# 465 with default recursion limit
96+
nest_count = int(sys.getrecursionlimit() * 0.465)
9797
recursive_array_toml = "arr = " + nest_count * "[" + nest_count * "]"
9898
tomllib.loads(recursive_array_toml)
9999

0 commit comments

Comments
 (0)