Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCHv1] [long] improvements to limit/ulimit API and doc
2020-11-26 20:19:37 +0900, Jun T:
> This is not the problem of the patch, but I noticed limit/ulimit of zsh
> has a small problem due to the wrap-around of unsigned integers.
> For example, on Linux, either with or without Stephane's patch:
>
> zsh% ulimit 36028797018963967 && ulimit
> 36028797018963967 # = 2**55 - 1
> zsh% ulimit 36028797018963968 && ulimit
> 0
>
> This is because 36028797018963968 blocks = 2**64, which wrap around to zero.
> With the patch we can more easily see:
>
> zsh% limit filesize 8EiB && limit filesize
> filesize 8EiB
> zsh% limit filesize 16EiB && limit fillesize
> filesize 0B # 16EiB = 2**64 = 0
>
> It seems bash is doing some check for the wrap around:
>
> zsh% bash --posix # block=512B in POSIX mode
> bash$ ulimit 36028797018963967 && ulimit
> 36028797018963967
> bash$ ulimit 36028797018963968
> bash: ulimit: 36028797018963968: limit out of range
But:
$ bash --posix -c 'ulimit 18446744073709551617; ulimit'
1
There's also the question of the actual value of RLIM_INFINITY,
RLIM_SAVED_MAX, RLIM_SAVED_CUR and whether we can assume
RLIM_INFINITY is the maximum possible value.
POSIX doesn't seem to give us much guarantee there
(https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/sys_resource.h.html)
> In B12limit.ztst
>
> > + if sh -c 'ulimit 2048' > /dev/null 2>&1; then
>
> Can we assume that there is no hard limit set by the System?
> Later in the test we will test up to 1EiB, so maybe it would be safer
> to use 'ulimit -f unlimited'?
> (All the systems I know do not set any hard limit on filesize
> so maybe we need not bother with this).
Yes, "make test" is meant for packagers. I'd say it's up to them
to update their environment so the tests can run.
Now, I'd expect those 1EiB tests would fail on some system
whether or not "ulimit -f unlimited" works or not. I haven't
found any yet. But if there are any, it's probably better we be
told about it (and a failing test is a good way to achieve
that).
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author