Limit stack size to 16 MB on Darwin

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-11-07 15:32:34 +01:00
parent 4c50e3abb9
commit b54bf7c0f9
1 changed files with 4 additions and 1 deletions

View File

@ -34,9 +34,12 @@ if os.name == "posix":
if sys.getrecursionlimit() < smtio_reclimit: if sys.getrecursionlimit() < smtio_reclimit:
sys.setrecursionlimit(smtio_reclimit) sys.setrecursionlimit(smtio_reclimit)
smtio_stacksize = 128 * 1024 * 1024
current_rlimit_stack = resource.getrlimit(resource.RLIMIT_STACK) current_rlimit_stack = resource.getrlimit(resource.RLIMIT_STACK)
if current_rlimit_stack[0] != resource.RLIM_INFINITY: if current_rlimit_stack[0] != resource.RLIM_INFINITY:
smtio_stacksize = 128 * 1024 * 1024
if os.uname().sysname == "Darwin":
# MacOS has rather conservative stack limits
smtio_stacksize = 16 * 1024 * 1024
if current_rlimit_stack[1] != resource.RLIM_INFINITY: if current_rlimit_stack[1] != resource.RLIM_INFINITY:
smtio_stacksize = min(smtio_stacksize, current_rlimit_stack[1]) smtio_stacksize = min(smtio_stacksize, current_rlimit_stack[1])
if current_rlimit_stack[0] < smtio_stacksize: if current_rlimit_stack[0] < smtio_stacksize: