]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117008: Fix functools test_recursive_pickle() (#117009)
authorVictor Stinner <vstinner@python.org>
Sat, 23 Mar 2024 12:01:20 +0000 (13:01 +0100)
committerGitHub <noreply@github.com>
Sat, 23 Mar 2024 12:01:20 +0000 (13:01 +0100)
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.

Include/cpython/pystate.h
Lib/test/test_functools.py

index f1540fde925921c421d5324613b04d6a3d860aa8..7fb6b176392173380f3940bcd6963de0cdd3d123 100644 (file)
@@ -209,6 +209,8 @@ struct _ts {
 #  define Py_C_RECURSION_LIMIT 500
 #elif defined(__s390x__)
 #  define Py_C_RECURSION_LIMIT 800
+#elif defined(_WIN32) && defined(_M_ARM64)
+#  define Py_C_RECURSION_LIMIT 1000
 #elif defined(_WIN32)
 #  define Py_C_RECURSION_LIMIT 3000
 #elif defined(__ANDROID__)
index 1a6d8afe6ed6fe62b92c27ab49ef0f5d71a2023e..3ba4929dd1b13309b1e21290c21c674a2ce253d3 100644 (file)
@@ -334,8 +334,10 @@ class TestPartial:
             f.__setstate__((f, (), {}, {}))
             try:
                 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
-                    with self.assertRaises(RecursionError):
-                        pickle.dumps(f, proto)
+                    # gh-117008: Small limit since pickle uses C stack memory
+                    with support.infinite_recursion(100):
+                        with self.assertRaises(RecursionError):
+                            pickle.dumps(f, proto)
             finally:
                 f.__setstate__((capture, (), {}, {}))