Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Increase the maximum marshal recursion depth on Windows debug builds.
  • Loading branch information
serhiy-storchaka committed Jul 4, 2018
commit f97d50c78455b0654db6abd9b6b557592a9ec763
8 changes: 1 addition & 7 deletions Lib/test/test_marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,7 @@ def test_recursion_limit(self):
# Create a deeply nested structure.
head = last = []
# The max stack depth should match the value in Python/marshal.c.
# 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
MAX_MARSHAL_STACK_DEPTH = 2000
for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
last.append([0])
last = last[-1]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Reduces maximum marshal recursion depth on release builds.
Increased the maximum marshal recursion depth on Windows debug builds.
It is now the same on all platforms.
11 changes: 0 additions & 11 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ module marshal
/* 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.
*
* 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)
#define MAX_MARSHAL_STACK_DEPTH 1000
#else
#define MAX_MARSHAL_STACK_DEPTH 2000
#endif

#define TYPE_NULL '0'
#define TYPE_NONE 'N'
Expand Down