[Python-checkins] bpo-33720: Reduces maximum marshal recursion depth on release builds. (GH-7401)
Steve Dower
webhook-mailer at python.org
Mon Jun 4 16:25:04 EDT 2018
https://github.com/python/cpython/commit/2a4a62ba4ae770bbc7b7fdec0760031c83fe1f7b
commit: 2a4a62ba4ae770bbc7b7fdec0760031c83fe1f7b
branch: master
author: Steve Dower <steve.dower at microsoft.com>
committer: GitHub <noreply at github.com>
date: 2018-06-04T13:25:00-07:00
summary:
bpo-33720: Reduces maximum marshal recursion depth on release builds. (GH-7401)
files:
A Misc/NEWS.d/next/Windows/2018-06-04-09-20-53.bpo-33720.VKDXHK.rst
M Lib/test/test_marshal.py
M Python/marshal.c
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 29dda987d0bb..a8a43d22bc36 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -222,7 +222,10 @@ def test_recursion_limit(self):
# Create a deeply nested structure.
head = last = []
# The max stack depth should match the value in Python/marshal.c.
- if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
+ # BUG: https://bugs.python.org/issue33720
+ # Windows always limits the maximum depth on release and debug builds
+ #if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
+ if os.name == 'nt':
MAX_MARSHAL_STACK_DEPTH = 1000
else:
MAX_MARSHAL_STACK_DEPTH = 2000
diff --git a/Misc/NEWS.d/next/Windows/2018-06-04-09-20-53.bpo-33720.VKDXHK.rst b/Misc/NEWS.d/next/Windows/2018-06-04-09-20-53.bpo-33720.VKDXHK.rst
new file mode 100644
index 000000000000..f7e2f9d1eae4
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2018-06-04-09-20-53.bpo-33720.VKDXHK.rst
@@ -0,0 +1 @@
+Reduces maximum marshal recursion depth on release builds.
diff --git a/Python/marshal.c b/Python/marshal.c
index e23daf6497b4..6d06266c6a8e 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -25,8 +25,14 @@ module marshal
* 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.
+ *
+ * BUG: https://bugs.python.org/issue33720
+ * On Windows PGO builds, the r_object function overallocates its stack and
+ * can cause a stack overflow. We reduce the maximum depth for all Windows
+ * releases to protect against this.
+ * #if defined(MS_WINDOWS) && defined(_DEBUG)
*/
-#if defined(MS_WINDOWS) && defined(_DEBUG)
+#if defined(MS_WINDOWS)
#define MAX_MARSHAL_STACK_DEPTH 1000
#else
#define MAX_MARSHAL_STACK_DEPTH 2000
More information about the Python-checkins
mailing list