]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-98925: Lower marshal recursion depth for WASI (GH-98938) (GH-98979)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 1 Nov 2022 23:18:55 +0000 (16:18 -0700)
committerGitHub <noreply@github.com>
Tue, 1 Nov 2022 23:18:55 +0000 (16:18 -0700)
* 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 9711265182f163ba381e7800e3748ac28710f9ef)

Co-authored-by: Brett Cannon <brett@python.org>
.gitignore
Lib/test/test_marshal.py
Misc/NEWS.d/next/Core and Builtins/2022-10-31-18-03-10.gh-issue-98925.zpdjVd.rst [new file with mode: 0644]
Python/marshal.c

index b3b22f471c2765cce3d3c8927264cb5790dac0cc..d42e111666f1e9d164720b3a5ca1e05e7d5d3248 100644 (file)
@@ -114,6 +114,7 @@ PCbuild/win32/
 Tools/unicode/data/
 /autom4te.cache
 /build/
+/builddir/
 /config.cache
 /config.log
 /config.status
index aae86cc257d7e13a623a5e81a0abd6dd41a54b27..f5956fc3a15a009a74245313d0aa7424ac267f04 100644 (file)
@@ -259,6 +259,8 @@ class BugsTestCase(unittest.TestCase):
         #if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
         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):
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-10-31-18-03-10.gh-issue-98925.zpdjVd.rst b/Misc/NEWS.d/next/Core and Builtins/2022-10-31-18-03-10.gh-issue-98925.zpdjVd.rst
new file mode 100644 (file)
index 0000000..6f23969
--- /dev/null
@@ -0,0 +1,2 @@
+Lower the recursion depth for marshal on WASI to support
+wasmtime 2.0/main.
index 90a440509180060eb2214ebf9999b9ba6bf0e996..2690f55766c83bf1851a523ab91267e96f22014a 100644 (file)
@@ -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