New submission from marche147 <bitmar...@gmail.com>:
Consider the following code: ``` import resource s, h = resource.getrlimit(resource.RLIMIT_STACK) resource.setrlimit(resource.RLIMIT_STACK, (h, h)) ``` Running this under macOS with python 3.6.5 gives the following exception: ``` bash-3.2$ uname -a Darwin arch-osx 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64 bash-3.2$ cat test.py import resource s, h = resource.getrlimit(resource.RLIMIT_STACK) resource.setrlimit(resource.RLIMIT_STACK, (h, h)) bash-3.2$ python3 test.py Traceback (most recent call last): File "test.py", line 3, in <module> resource.setrlimit(resource.RLIMIT_STACK, (h, h)) ValueError: current limit exceeds maximum limit ``` Nevertheless, when using python 2.7.10 under the same environment, this code works perfectly without exceptions being thrown. Additionally, neither of these operations fail under the same circumstances : ``` bash-3.2$ cat test.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <sys/resource.h> int main() { struct rlimit rl; if(getrlimit(RLIMIT_STACK, &rl) < 0) { perror("getrlimit"); exit(1); } rl.rlim_cur = rl.rlim_max; if(setrlimit(RLIMIT_STACK, &rl) < 0) { perror("setrlimit"); exit(1); } return 0; } bash-3.2$ gcc -o test test.c bash-3.2$ ./test ``` ``` bash-3.2$ ulimit -s -H 65532 bash-3.2$ ulimit -s 8192 bash-3.2$ ulimit -s 65532 bash-3.2$ ulimit -s 65532 ``` I have also tried to run the above-mentioned python script on linux, also it does not generate exceptions both on python2 (2.7.10) & python3 (3.6.5). ---------- components: Library (Lib) messages: 324731 nosy: marche147 priority: normal severity: normal status: open title: python3 resource.setrlimit strange behaviour under macOS type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34602> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com