home ~ # ssh root@10.0.1.34 GlobalOS 2.1 http://www.globalos.info/ Proxy-16 ~ # ulimit -n 262144 ash: error setting limit: Invalid argument Proxy-16 ~ # ulimit -n 2048 ash: error setting limit: Invalid argument Proxy-16 ~ # ulimit -n 1025 ash: error setting limit: Invalid argument Proxy-16 ~ # ulimit -n 1024 Proxy-16 ~ #
And even more bad: bash2 is full blown bash Proxy-16 ~ # bash2 Proxy-16 ~ # ulimit -n 262144 Proxy-16 ~ # ulimit -n 262144 Proxy-16 ~ # exit Proxy-16 ~ # ulimit -n 1024 Proxy-16 ~ # bash2 Proxy-16 ~ # ulimit -n 1024 So just by viewing ulimit it will be reversed back
Hold on, seems i am unable to reproduce this bug on full-blown system, i will make sure it is not GCC or kernel bug.
Tested, seems it is issue in busybox. busybox 1.16.2 works fine, 1.17.0 fails. I try to use gcc 3.3.6, it is still failing, i try even to change glibc from 2.10.1 to 2.11.2 - it is still not changing ulimit. I can reproduce it also in normal linux system: /WORK/globalosii/devel/BUSYBOX/busybox-1.17.1 # ulimit -n 10240 ash: error setting limit: Invalid argument Interesting, if i launch busybox over valgrind it shows /WORK/globalosii/devel/BUSYBOX/busybox-1.17.1 # ulimit -n 1014
Seems i found reason If i add if (opts & OPT_hard) limit.rlim_max = val; if ((opts & OPT_soft) || opts == 0) limit.rlim_cur = val; + if (limit.rlim_max < limit.rlim_cur) + limit.rlim_max = limit.rlim_cur; //bb_error_msg("setrlimit(%d, %lld, %lld)", l->cmd, (long long)limit.rlim_cur, (long long)limit.rlim_max); printf("Setrlimit call\n"); if (setrlimit(l->cmd, &limit) < 0) { bb_perror_msg("error setting limit"); Problem will disappear. This is how bash do ulimit -n 1025 by strace getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 setrlimit(RLIMIT_NOFILE, {rlim_cur=1025, rlim_max=1025}) = 0 This is how unpatched busybox getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0 setrlimit(RLIMIT_NOFILE, {rlim_cur=1025, rlim_max=1024}) = -1 EINVAL (Invalid argument)
(1) try http://busybox.net/downloads/fixes-1.17.1/busybox-1.17.1-shell.patch (2) if patched busybox fails too, strace failing ulimit invocation and similar bash invocation: strace -oLOG.ash -s99 /path/to/busybox ash -c 'ulimit -n NUM' strace -oLOG.bash -s99 bash -c 'ulimit -n NUM' and attach LOG* files to this bug.
Closing, since hotfix at http://busybox.net/downloads/fixes-1.17.1/busybox-1.17.1-shell.patch ought to be the fix for this.