bpo-33720: Reduces maximum marshal recursion depth on release builds. (GH-7401)
(cherry picked from commit 2a4a62ba4a
)
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
This commit is contained in:
parent
150033d159
commit
103058e19b
|
@ -222,7 +222,10 @@ class BugsTestCase(unittest.TestCase):
|
||||||
# Create a deeply nested structure.
|
# Create a deeply nested structure.
|
||||||
head = last = []
|
head = last = []
|
||||||
# The max stack depth should match the value in Python/marshal.c.
|
# 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
|
MAX_MARSHAL_STACK_DEPTH = 1000
|
||||||
else:
|
else:
|
||||||
MAX_MARSHAL_STACK_DEPTH = 2000
|
MAX_MARSHAL_STACK_DEPTH = 2000
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Reduces maximum marshal recursion depth on release builds.
|
|
@ -25,8 +25,14 @@ module marshal
|
||||||
* and risks coring the interpreter. When the object stack gets this deep,
|
* and risks coring the interpreter. When the object stack gets this deep,
|
||||||
* raise an exception instead of continuing.
|
* raise an exception instead of continuing.
|
||||||
* On Windows debug builds, reduce this value.
|
* 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
|
#define MAX_MARSHAL_STACK_DEPTH 1000
|
||||||
#else
|
#else
|
||||||
#define MAX_MARSHAL_STACK_DEPTH 2000
|
#define MAX_MARSHAL_STACK_DEPTH 2000
|
||||||
|
|
Loading…
Reference in New Issue