Skip to content

Commit

Permalink
pythongh-98925: Lower marshal recursion depth for WASI
Browse files Browse the repository at this point in the history
For (in-development) wasmtime 2.0, the stack depth cost is 6% higher. As the default is 2000 and Windows is 1000, split the difference and choose 1500 for WASI.
  • Loading branch information
brettcannon committed Nov 1, 2022
1 parent 88297e2 commit 921f4c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
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 921f4c5

Please sign in to comment.