summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2023-11-20 13:27:33 (GMT)
committerGitHub <noreply@github.com>2023-11-20 13:27:33 (GMT)
commit56e59a49ae4d9f518c5cc918aefe7eeee11736b4 (patch)
tree4516ddb2f716a9fd42c3c155e994230bfed89a8d
parentce1096f974d3158a92e050f9226700775b8db398 (diff)
downloadcpython-56e59a49ae4d9f518c5cc918aefe7eeee11736b4.zip
cpython-56e59a49ae4d9f518c5cc918aefe7eeee11736b4.tar.gz
cpython-56e59a49ae4d9f518c5cc918aefe7eeee11736b4.tar.bz2
GH-111807: Lower the parser stack depth under WASI debug builds (#112225)
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-11-17-16-49-32.gh-issue-111807.QvjP9_.rst1
-rw-r--r--Parser/parser.c6
-rw-r--r--Tools/peg_generator/pegen/c_generator.py6
3 files changed, 11 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-11-17-16-49-32.gh-issue-111807.QvjP9_.rst b/Misc/NEWS.d/next/Core and Builtins/2023-11-17-16-49-32.gh-issue-111807.QvjP9_.rst
new file mode 100644
index 0000000..6f07584
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-11-17-16-49-32.gh-issue-111807.QvjP9_.rst
@@ -0,0 +1 @@
+Lower the max parser stack depth to 1000 under WASI debug builds.
diff --git a/Parser/parser.c b/Parser/parser.c
index ca8e9d0..d27ddd3 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -8,7 +8,11 @@
#endif
#ifdef __wasi__
-# define MAXSTACK 4000
+# ifdef Py_DEBUG
+# define MAXSTACK 1000
+# else
+# define MAXSTACK 4000
+# endif
#else
# define MAXSTACK 6000
#endif
diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index 301949b..7cdd5de 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -38,7 +38,11 @@ EXTENSION_PREFIX = """\
#endif
#ifdef __wasi__
-# define MAXSTACK 4000
+# ifdef Py_DEBUG
+# define MAXSTACK 1000
+# else
+# define MAXSTACK 4000
+# endif
#else
# define MAXSTACK 6000
#endif