]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
On Max OSX, try increasing the stack limit to 2048 so test_re and
authorGuido van Rossum <guido@python.org>
Mon, 2 Dec 2002 09:56:21 +0000 (09:56 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 2 Dec 2002 09:56:21 +0000 (09:56 +0000)
test_sre won't die with a SegFault.

Lib/test/regrtest.py

index 1590ab1e8424d165b31dfd687b9b331a8255bed3..ffb49ab73867ae7184d3205bb40c266418be2354 100755 (executable)
@@ -83,6 +83,22 @@ if sys.maxint > 0x7fffffff:
     warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
                             "<string>")
 
+# MacOSX (a.k.a. Darwin) has a default stack size that is too small
+# for deeply recursive regular expressions.  We see this as crashes in
+# the Python test suite when running test_re.py and test_sre.py.  The
+# fix is to set the stack limit to 2048.
+# This approach may also be useful for other Unixy platforms that
+# suffer from small default stack limits.
+if sys.platform == 'darwin':
+    try:
+        import resource
+    except ImportError:
+        pass
+    else:
+        soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
+        newsoft = min(hard, max(soft, 1024*2048))
+        resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
+
 from test import test_support
 
 RESOURCE_NAMES = ('curses', 'largefile', 'network', 'bsddb')