From 64c82753de70f312c80797f63b6b8b98232b6f0f Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 6 Jul 2016 23:37:02 -0700 Subject: [PATCH] reduce marshal stack size in debug mode on windows (closes #27019) --- Lib/test/test_marshal.py | 5 ++++- Python/marshal.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 1967c4807e..76d59bac39 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -234,7 +234,10 @@ class BugsTestCase(unittest.TestCase): # Create a deeply nested structure. head = last = [] # The max stack depth should match the value in Python/marshal.c. - MAX_MARSHAL_STACK_DEPTH = 2000 + if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'): + MAX_MARSHAL_STACK_DEPTH = 1000 + else: + MAX_MARSHAL_STACK_DEPTH = 2000 for i in range(MAX_MARSHAL_STACK_DEPTH - 2): last.append([0]) last = last[-1] diff --git a/Python/marshal.c b/Python/marshal.c index 6b285aaa41..e1a84d0bf7 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -16,8 +16,13 @@ /* High water mark to determine when the marshalled object is dangerously deep * and risks coring the interpreter. When the object stack gets this deep, * raise an exception instead of continuing. + * On Windows debug builds, reduce this value. */ +#if defined(MS_WINDOWS) && defined(_DEBUG) +#define MAX_MARSHAL_STACK_DEPTH 1000 +#else #define MAX_MARSHAL_STACK_DEPTH 2000 +#endif #define TYPE_NULL '0' #define TYPE_NONE 'N' -- 2.50.1