[Python-Dev] Mac OSX issues

Barry A. Warsaw barry@python.org
Sun, 1 Dec 2002 23:39:13 -0500


>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:

    GvR> - test_re crashes unless I do ulimit -s 2000 -- haven't tried
    GvR> other values, but the default of 512 (KB) is insufficient.  I
    GvR> know the README file explains this, but now that I've
    GvR> experienced this myself, I wonder if we shouldn't hack main()
    GvR> to increase the stack size to 2 MB, inside an #ifdef darwin
    GvR> or something like that.

+1, but I'll defer to Jack.  We discussed this a while back (for
Py2.2.2 IIRC), which is when I updated the README bit.  FWIW,
Pipermail (in Mailman) suffers the same fate and contains the
following bit of code.

-Barry

-------------------- snip snip --------------------
# MacOSX 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; the general recommendation is to do in the shell before running the
# test suite.  But that's inconvenient for a daemon like the qrunner.
#
# AFAIK, this problem only affects the archiver, so we're adding this work
# around to this file (it'll get imported by the bundled pipermail or by the
# bin/arch script.  We also only do this on darwin, a.k.a. MacOSX.
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))