bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546) · python/cpython@bd92b94

4 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -58,22 +58,6 @@ def setup_tests(ns):

5858

if getattr(module, '__file__', None):

5959

module.__file__ = os.path.abspath(module.__file__)

6060
61-

# MacOSX (a.k.a. Darwin) has a default stack size that is too small

62-

# for deeply recursive regular expressions. We see this as crashes in

63-

# the Python test suite when running test_re.py and test_sre.py. The

64-

# fix is to set the stack limit to 2048.

65-

# This approach may also be useful for other Unixy platforms that

66-

# suffer from small default stack limits.

67-

if sys.platform == 'darwin':

68-

try:

69-

import resource

70-

except ImportError:

71-

pass

72-

else:

73-

soft, hard = resource.getrlimit(resource.RLIMIT_STACK)

74-

newsoft = min(hard, max(soft, 1024*2048))

75-

resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))

76-
7761

if ns.huntrleaks:

7862

unittest.BaseTestSuite._cleanup = False

7963
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change

@@ -9524,6 +9524,12 @@ then

95249524

# -u libsys_s pulls in all symbols in libsys

95259525

Darwin/*)

95269526

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+
95279533

if test "$enable_framework"

95289534

then

95299535

LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'

Original file line numberDiff line numberDiff line change

@@ -2682,6 +2682,12 @@ then

26822682

# -u libsys_s pulls in all symbols in libsys

26832683

Darwin/*)

26842684

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+
26852691

if test "$enable_framework"

26862692

then

26872693

LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'