Skip to content

Commit

Permalink
pythongh-98925: Lower marshal recursion depth for WASI (pythonGH-98938)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brettcannon committed Nov 1, 2022
1 parent c085974 commit 9711265
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ PCbuild/win32/
Tools/unicode/data/
/autom4te.cache
/build/
/builddir/
/config.cache
/config.log
/config.status
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ def test_recursion_limit(self):
#if os.name == 'nt' and support.Py_DEBUG:
if os.name == 'nt':
MAX_MARSHAL_STACK_DEPTH = 1000
elif sys.platform == 'wasi':
MAX_MARSHAL_STACK_DEPTH = 1500
else:
MAX_MARSHAL_STACK_DEPTH = 2000
for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Lower the recursion depth for marshal on WASI to support (in-development)
wasmtime 2.0.
2 changes: 2 additions & 0 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module marshal
*/
#if defined(MS_WINDOWS)
#define MAX_MARSHAL_STACK_DEPTH 1000
#elif defined(__wasi__)
#define MAX_MARSHAL_STACK_DEPTH 1500
#else
#define MAX_MARSHAL_STACK_DEPTH 2000
#endif
Expand Down

0 comments on commit 9711265

Please sign in to comment.