From 56e59a49ae4d9f518c5cc918aefe7eeee11736b4 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 20 Nov 2023 05:27:33 -0800 Subject: [PATCH] GH-111807: Lower the parser stack depth under WASI debug builds (#112225) --- .../2023-11-17-16-49-32.gh-issue-111807.QvjP9_.rst | 1 + Parser/parser.c | 6 +++++- Tools/peg_generator/pegen/c_generator.py | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-11-17-16-49-32.gh-issue-111807.QvjP9_.rst 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 00000000000000..6f075845e11b86 --- /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 ca8e9d0e23661c..d27ddd3d3e3835 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 301949bdae96fe..7cdd5debe9a225 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -38,7 +38,11 @@ #endif #ifdef __wasi__ -# define MAXSTACK 4000 +# ifdef Py_DEBUG +# define MAXSTACK 1000 +# else +# define MAXSTACK 4000 +# endif #else # define MAXSTACK 6000 #endif