Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9967b56

Browse files
authored
gh-117008: Fix functools test_recursive_pickle() (#117009)
Use support.infinite_recursion() in test_recursive_pickle() of test_functools to prevent a stack overflow on "ARM64 Windows Non-Debug" buildbot. Lower Py_C_RECURSION_LIMIT to 1,000 frames on Windows ARM64.
1 parent 72eea51 commit 9967b56

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Include/cpython/pystate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ struct _ts {
209209
# define Py_C_RECURSION_LIMIT 500
210210
#elif defined(__s390x__)
211211
# define Py_C_RECURSION_LIMIT 800
212+
#elif defined(_WIN32) && defined(_M_ARM64)
213+
# define Py_C_RECURSION_LIMIT 1000
212214
#elif defined(_WIN32)
213215
# define Py_C_RECURSION_LIMIT 3000
214216
#elif defined(__ANDROID__)

Lib/test/test_functools.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ def test_recursive_pickle(self):
334334
f.__setstate__((f, (), {}, {}))
335335
try:
336336
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
337-
with self.assertRaises(RecursionError):
338-
pickle.dumps(f, proto)
337+
# gh-117008: Small limit since pickle uses C stack memory
338+
with support.infinite_recursion(100):
339+
with self.assertRaises(RecursionError):
340+
pickle.dumps(f, proto)
339341
finally:
340342
f.__setstate__((capture, (), {}, {}))
341343

0 commit comments

Comments
 (0)