diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-11-07 20:16:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 20:16:40 +0100 |
commit | 825b4c1aa9ae5abe7484f056cc14d973bcaae378 (patch) | |
tree | f6e37def919addfd01223aba2aea808139a14ac1 /backends/smt2 | |
parent | 7bd2144d03ae5daffbcddea609d2db7df7b751a2 (diff) | |
parent | b54bf7c0f9720526dffce684ef1353b81f99547c (diff) | |
download | yosys-825b4c1aa9ae5abe7484f056cc14d973bcaae378.tar.gz yosys-825b4c1aa9ae5abe7484f056cc14d973bcaae378.tar.bz2 yosys-825b4c1aa9ae5abe7484f056cc14d973bcaae378.zip |
Merge pull request #693 from YosysHQ/rlimit
improve rlimit handling in smtio.py
Diffstat (limited to 'backends/smt2')
-rw-r--r-- | backends/smt2/smtio.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/backends/smt2/smtio.py b/backends/smt2/smtio.py index 4c3245984..68783e744 100644 --- a/backends/smt2/smtio.py +++ b/backends/smt2/smtio.py @@ -31,16 +31,19 @@ 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)) + + current_rlimit_stack = resource.getrlimit(resource.RLIMIT_STACK) + 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: + smtio_stacksize = min(smtio_stacksize, current_rlimit_stack[1]) + 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) |