Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9711265

Browse files
authored
gh-98925: Lower marshal recursion depth for WASI (GH-98938)
For wasmtime 2.0, the stack depth cost is 6% higher. This causes the default max `marshal` recursion depth to blow the stack. As the default marshal depth is 2000 and Windows is set to 1000, split the difference and choose 1500 for WASI to be safe.
1 parent c085974 commit 9711265

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ PCbuild/win32/
116116
Tools/unicode/data/
117117
/autom4te.cache
118118
/build/
119+
/builddir/
119120
/config.cache
120121
/config.log
121122
/config.status

Lib/test/test_marshal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ def test_recursion_limit(self):
260260
#if os.name == 'nt' and support.Py_DEBUG:
261261
if os.name == 'nt':
262262
MAX_MARSHAL_STACK_DEPTH = 1000
263+
elif sys.platform == 'wasi':
264+
MAX_MARSHAL_STACK_DEPTH = 1500
263265
else:
264266
MAX_MARSHAL_STACK_DEPTH = 2000
265267
for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Lower the recursion depth for marshal on WASI to support (in-development)
2+
wasmtime 2.0.

Python/marshal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ module marshal
3434
*/
3535
#if defined(MS_WINDOWS)
3636
#define MAX_MARSHAL_STACK_DEPTH 1000
37+
#elif defined(__wasi__)
38+
#define MAX_MARSHAL_STACK_DEPTH 1500
3739
#else
3840
#define MAX_MARSHAL_STACK_DEPTH 2000
3941
#endif

0 commit comments

Comments
 (0)