diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-11-06 10:05:23 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-11-06 10:05:23 +0100 |
commit | 79075d123f749ad39bf35f658f00a79a24efcf98 (patch) | |
tree | b91383c85fb3de6b7359ba228376421550ae7a6e /backends/smt2/smtio.py | |
parent | 719e29404a74db8f994c9c3dc0d6b6e8d7f114a7 (diff) | |
download | yosys-79075d123f749ad39bf35f658f00a79a24efcf98.tar.gz yosys-79075d123f749ad39bf35f658f00a79a24efcf98.tar.bz2 yosys-79075d123f749ad39bf35f658f00a79a24efcf98.zip |
Improve stack rlimit code in smtio.py
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'backends/smt2/smtio.py')
-rw-r--r-- | backends/smt2/smtio.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/backends/smt2/smtio.py b/backends/smt2/smtio.py index e8ed5e63b..e417b7758 100644 --- a/backends/smt2/smtio.py +++ b/backends/smt2/smtio.py @@ -31,16 +31,16 @@ from threading import Thread # does not run out of stack frames when parsing large expressions if os.name == "posix": smtio_reclimit = 64 * 1024 - smtio_stacksize = 128 * 1024 * 1024 - smtio_stacklimit = resource.RLIM_INFINITY - if os.uname().sysname == "Darwin": - # MacOS has rather conservative stack limits - smtio_stacksize = 16 * 1024 * 1024 - smtio_stacklimit = resource.getrlimit(resource.RLIMIT_STACK)[1] if sys.getrecursionlimit() < smtio_reclimit: sys.setrecursionlimit(smtio_reclimit) - if resource.getrlimit(resource.RLIMIT_STACK)[0] < smtio_stacksize: - resource.setrlimit(resource.RLIMIT_STACK, (smtio_stacksize, smtio_stacklimit)) + + smtio_stacksize = 128 * 1024 * 1024 + current_rlimit_stack = resource.getrlimit(resource.RLIMIT_STACK) + if current_rlimit_stack[0] != resource.RLIM_INFINITY: + if current_rlimit_stack[1] != resource.RLIM_INFINITY: + smtio_stacksize = min(smtio_stacksize, smtio_stacklimit) + if current_rlimit_stack[0] < smtio_stacksize: + resource.setrlimit(resource.RLIMIT_STACK, (smtio_stacksize, current_rlimit_stack[1])) # currently running solvers (so we can kill them) |