bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546) · python/cpython@5bbbc73 (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -60,22 +60,6 @@ def setup_tests(ns): | ||
60 | 60 | if getattr(module, '__file__', None): |
61 | 61 | module.__file__ = os.path.abspath(module.__file__) |
62 | 62 | |
63 | -# MacOSX (a.k.a. Darwin) has a default stack size that is too small | |
64 | -# for deeply recursive regular expressions. We see this as crashes in | |
65 | -# the Python test suite when running test_re.py and test_sre.py. The | |
66 | -# fix is to set the stack limit to 2048. | |
67 | -# This approach may also be useful for other Unixy platforms that | |
68 | -# suffer from small default stack limits. | |
69 | -if sys.platform == 'darwin': | |
70 | -try: | |
71 | -import resource | |
72 | -except ImportError: | |
73 | -pass | |
74 | -else: | |
75 | -soft, hard = resource.getrlimit(resource.RLIMIT_STACK) | |
76 | -newsoft = min(hard, max(soft, 1024*2048)) | |
77 | -resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) | |
78 | - | |
79 | 63 | if ns.huntrleaks: |
80 | 64 | unittest.BaseTestSuite._cleanup = False |
81 | 65 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 | +Avoid test suite failures on macOS by no longer calling resource.setrlimit | |
2 | +to increase the process stack size limit at runtime. The runtime change is | |
3 | +no longer needed since the interpreter is being built with a larger default | |
4 | +stack size. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -9524,6 +9524,12 @@ then | ||
9524 | 9524 | # -u libsys_s pulls in all symbols in libsys |
9525 | 9525 | Darwin/*) |
9526 | 9526 | LINKFORSHARED="$extra_undefs -framework CoreFoundation" |
9527 | + | |
9528 | +# Issue #18075: the default maximum stack size (8MBytes) is too | |
9529 | +# small for the default recursion limit. Increase the stack size | |
9530 | +# to ensure that tests don't crash | |
9531 | + LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED" | |
9532 | + | |
9527 | 9533 | if test "$enable_framework" |
9528 | 9534 | then |
9529 | 9535 | LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2682,6 +2682,12 @@ then | ||
2682 | 2682 | # -u libsys_s pulls in all symbols in libsys |
2683 | 2683 | Darwin/*) |
2684 | 2684 | LINKFORSHARED="$extra_undefs -framework CoreFoundation" |
2685 | + | |
2686 | +# Issue #18075: the default maximum stack size (8MBytes) is too | |
2687 | +# small for the default recursion limit. Increase the stack size | |
2688 | +# to ensure that tests don't crash | |
2689 | + LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED" | |
2690 | + | |
2685 | 2691 | if test "$enable_framework" |
2686 | 2692 | then |
2687 | 2693 | LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' |