From 921f4c5dec3df9d6674250f53032e405b1278525 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 31 Oct 2022 18:05:04 -0700 Subject: [PATCH 1/3] gh-98925: Lower marshal recursion depth for WASI 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. --- Lib/test/test_marshal.py | 2 ++ .../2022-10-31-18-03-10.gh-issue-98925.zpdjVd.rst | 2 ++ Python/marshal.c | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-10-31-18-03-10.gh-issue-98925.zpdjVd.rst diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index fe4f368bed42f4..54c5a324897d23 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -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): 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 index 00000000000000..7c965dc752f70b --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-10-31-18-03-10.gh-issue-98925.zpdjVd.rst @@ -0,0 +1,2 @@ +Lower the recursion depth for marshal on WASI to support (in-development) +wasmtime 2.0. diff --git a/Python/marshal.c b/Python/marshal.c index 90a44050918006..5883464c0a5eda 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -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 From 0aaed2de4b7a0582f4a43e09966826bc7b9cbc75 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 31 Oct 2022 19:08:56 -0700 Subject: [PATCH 2/3] Fix the case-sensitivity for `__wasi__` --- Python/marshal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/marshal.c b/Python/marshal.c index 5883464c0a5eda..2690f55766c83b 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -34,7 +34,7 @@ module marshal */ #if defined(MS_WINDOWS) #define MAX_MARSHAL_STACK_DEPTH 1000 -#elif defined(__WASI__) +#elif defined(__wasi__) #define MAX_MARSHAL_STACK_DEPTH 1500 #else #define MAX_MARSHAL_STACK_DEPTH 2000 From 0f487cd614e7b10ddf677e2df07076c958df2a76 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 31 Oct 2022 19:12:20 -0700 Subject: [PATCH 3/3] Ignore `builddir/` in `.gitignore` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6934faa91e9874..5055e6d225c796 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,7 @@ PCbuild/win32/ Tools/unicode/data/ /autom4te.cache /build/ +/builddir/ /config.cache /config.log /config.status