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

Skip to content

Commit 39e0627

Browse files
[3.11] gh-98925: Lower marshal recursion depth for WASI (GH-98938) (GH-98979)
* 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. (cherry picked from commit 9711265) Co-authored-by: Brett Cannon <[email protected]>
1 parent cd6655a commit 39e0627

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
@@ -114,6 +114,7 @@ PCbuild/win32/
114114
Tools/unicode/data/
115115
/autom4te.cache
116116
/build/
117+
/builddir/
117118
/config.cache
118119
/config.log
119120
/config.status

Lib/test/test_marshal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ def test_recursion_limit(self):
259259
#if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
260260
if os.name == 'nt':
261261
MAX_MARSHAL_STACK_DEPTH = 1000
262+
elif sys.platform == 'wasi':
263+
MAX_MARSHAL_STACK_DEPTH = 1500
262264
else:
263265
MAX_MARSHAL_STACK_DEPTH = 2000
264266
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
2+
wasmtime 2.0/main.

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)