[Python-checkins] cpython (2.7): reduce marshal stack size in debug mode on windows (closes #27019)

benjamin.peterson python-checkins at python.org
Thu Jul 7 02:37:09 EDT 2016


https://hg.python.org/cpython/rev/6230ead06f65
changeset:   102275:6230ead06f65
branch:      2.7
parent:      102273:370b2985d462
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Jul 06 23:37:02 2016 -0700
summary:
  reduce marshal stack size in debug mode on windows (closes #27019)

files:
  Lib/test/test_marshal.py |  5 ++++-
  Python/marshal.c         |  5 +++++
  2 files changed, 9 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -234,7 +234,10 @@
         # 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
--- 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'

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list