On 11/04/2026 22:42, Pádraig Brady wrote:
Verified with:
make -j4 PREFERABLY_POSIX_SHELL=/bin/ksh SUBDIRS=. check
* tests/fold/fold-zero-width.sh: Don't timeout $SHELL -c ...
as the ulimit induces a failure in the subshell depending
on the order of the allocations it does. The main issue is
disparity between the probed ulimit and that needed by $SHELL -c.
Such subshells load the often very large locale archive, thus
if there are any allocations done after the now too low ulimit is set,
then the $SHELL command fails.
---
tests/fold/fold-zero-width.sh | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tests/fold/fold-zero-width.sh b/tests/fold/fold-zero-width.sh
index 402b2b55e..933d09ca1 100755
--- a/tests/fold/fold-zero-width.sh
+++ b/tests/fold/fold-zero-width.sh
@@ -54,13 +54,12 @@ test $(wc -l < out) -eq $(($IO_BUFSIZE_TIMES2 / 80)) ||
fail=1
# Ensure bounded memory operation.
test -w /dev/full && test -c /dev/full &&
-vm=$(get_min_ulimit_v_ fold /dev/null) && {
+vm=$(get_min_ulimit_v_ timeout 10 fold /dev/null) && {
# \303 results in EILSEQ on input
for c in '\n' '\0' '\303'; do
- tr '\0' "$c" < /dev/zero | timeout 10 $SHELL -c \
- "(ulimit -v $(($vm+12000)) && fold 2>err >/dev/full)"
+ tr '\0' "$c" < /dev/zero |
+ (ulimit -v $(($vm+12000)) && timeout 10 fold 2>err >/dev/full)
ret=$?
- test -f err || skip_ 'shell ulimit failure'
{ test $ret = 124 || ! grep "$ENOSPC" err >/dev/null; } &&
{ fail=1; cat err; echo "fold didn't diagnose ENOSPC" >&2; }
done
More instances of this fixed in the attached.
cheers,
Padraig
From d58ea74d01f649664e82499884206231b8a82f6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Wed, 15 Apr 2026 15:08:27 +0100
Subject: [PATCH] tests: avoid $SHELL -c "ulimit ..." pattern
As described in commit v9.10-283-g5cb0cca3b
avoid using ulimit with $SHELL -c, and explict
invocation of the shell like that can require lots of memory,
often due to loading the locale archive.
* tests/basenc/bounded-memory.sh: Avoid $SHELL -c with ulimit.
* tests/cut/bounded-memory.sh: Likewise.
* tests/expand/bounded-memory.sh Likewise.
* tests/pr/bounded-memory.sh Likewise.
* tests/unexpand/bounded-memory.sh Likewise.
* tests/fold/fold-zero-width.sh: Bring the ulimit bound
down to the standard 6M over the determined limit.
---
tests/basenc/bounded-memory.sh | 8 +++-----
tests/cut/bounded-memory.sh | 8 +++-----
tests/expand/bounded-memory.sh | 8 +++-----
tests/fold/fold-zero-width.sh | 2 +-
tests/pr/bounded-memory.sh | 8 +++-----
tests/unexpand/bounded-memory.sh | 8 +++-----
6 files changed, 16 insertions(+), 26 deletions(-)
diff --git a/tests/basenc/bounded-memory.sh b/tests/basenc/bounded-memory.sh
index 166d54794..a34f7d3e3 100755
--- a/tests/basenc/bounded-memory.sh
+++ b/tests/basenc/bounded-memory.sh
@@ -19,17 +19,15 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ basenc
-vm=$(get_min_ulimit_v_ basenc --base64 /dev/null) ||
+vm=$(get_min_ulimit_v_ timeout 10 basenc --base64 /dev/null) ||
skip_ 'failed to determine memory limit'
# Check all except for --base58.
for algorithm in '--base64' '--base64url' '--base32' '--base32hex' '--base16' \
'--base2msbf' '--base2lsbf' '--z85'; do
- timeout 0.5 $SHELL -c \
- "(ulimit -v $(($vm+6000)) \
- && basenc $algorithm </dev/zero >/dev/null 2>err)"
+ (ulimit -v $(($vm+6000)) \
+ && timeout 0.5 basenc $algorithm </dev/zero >/dev/null 2>err)
ret=$?
- test -f err || skip_ 'shell ulimit failure'
test $ret = 124 || {
fail=1
cat err
diff --git a/tests/cut/bounded-memory.sh b/tests/cut/bounded-memory.sh
index 4c6014563..5c0018a74 100755
--- a/tests/cut/bounded-memory.sh
+++ b/tests/cut/bounded-memory.sh
@@ -19,17 +19,15 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cut
-vm=$(get_min_ulimit_v_ cut -b1 /dev/null) ||
+vm=$(get_min_ulimit_v_ timeout 10 cut -b1 /dev/null) ||
skip_ 'failed to determine memory limit'
# There is no way to implement '-s -f1' without allocating unbounded memory.
# Check the rest.
for opts in '-c1' '-b1' '-s -f2' '-f1'; do
- timeout 0.5 $SHELL -c \
- "(ulimit -v $(($vm+6000)) \
- && cut $opts </dev/zero >/dev/null 2>err)"
+ (ulimit -v $(($vm+6000)) \
+ && timeout 0.5 cut $opts </dev/zero >/dev/null 2>err)
ret=$?
- test -f err || skip_ 'shell ulimit failure'
test $ret = 124 || {
fail=1
cat err
diff --git a/tests/expand/bounded-memory.sh b/tests/expand/bounded-memory.sh
index 8b72e7f38..76cde9c65 100755
--- a/tests/expand/bounded-memory.sh
+++ b/tests/expand/bounded-memory.sh
@@ -19,14 +19,12 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ expand
-vm=$(get_min_ulimit_v_ expand /dev/null) ||
+vm=$(get_min_ulimit_v_ timeout 10 expand /dev/null) ||
skip_ 'failed to determine memory limit'
-timeout 0.5 $SHELL -c \
- "(ulimit -v $(($vm+6000)) \
- && expand </dev/zero >/dev/null 2>err)"
+(ulimit -v $(($vm+6000)) \
+ && timeout 0.5 expand </dev/zero >/dev/null 2>err)
ret=$?
-test -f err || skip_ 'shell ulimit failure'
test $ret = 124 || {
fail=1
cat err
diff --git a/tests/fold/fold-zero-width.sh b/tests/fold/fold-zero-width.sh
index 933d09ca1..1bec0ef34 100755
--- a/tests/fold/fold-zero-width.sh
+++ b/tests/fold/fold-zero-width.sh
@@ -58,7 +58,7 @@ vm=$(get_min_ulimit_v_ timeout 10 fold /dev/null) && {
# \303 results in EILSEQ on input
for c in '\n' '\0' '\303'; do
tr '\0' "$c" < /dev/zero |
- (ulimit -v $(($vm+12000)) && timeout 10 fold 2>err >/dev/full)
+ (ulimit -v $(($vm+6000)) && timeout 10 fold 2>err >/dev/full)
ret=$?
{ test $ret = 124 || ! grep "$ENOSPC" err >/dev/null; } &&
{ fail=1; cat err; echo "fold didn't diagnose ENOSPC" >&2; }
diff --git a/tests/pr/bounded-memory.sh b/tests/pr/bounded-memory.sh
index 90c265743..42083e92a 100755
--- a/tests/pr/bounded-memory.sh
+++ b/tests/pr/bounded-memory.sh
@@ -19,14 +19,12 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ pr
-vm=$(get_min_ulimit_v_ pr < /dev/null) ||
+vm=$(get_min_ulimit_v_ timeout 10 pr < /dev/null) ||
skip_ 'failed to determine memory limit'
-timeout 0.5 $SHELL -c \
- "(ulimit -v $(($vm+6000)) \
- && pr < /dev/zero > /dev/null 2>err)"
+(ulimit -v $(($vm+6000)) \
+ && timeout 0.5 pr < /dev/zero > /dev/null 2>err)
ret=$?
-test -f err || skip_ 'shell ulimit failure'
test $ret = 124 || {
fail=1
cat err
diff --git a/tests/unexpand/bounded-memory.sh b/tests/unexpand/bounded-memory.sh
index db3d365b4..d16f6c6b1 100755
--- a/tests/unexpand/bounded-memory.sh
+++ b/tests/unexpand/bounded-memory.sh
@@ -19,14 +19,12 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ unexpand
-vm=$(get_min_ulimit_v_ unexpand /dev/null) ||
+vm=$(get_min_ulimit_v_ timeout 10 unexpand /dev/null) ||
skip_ 'failed to determine memory limit'
-timeout 0.5 $SHELL -c \
- "(ulimit -v $(($vm+6000)) \
- && unexpand </dev/zero >/dev/null 2>err)"
+(ulimit -v $(($vm+6000)) \
+ && timeout 0.5 unexpand </dev/zero >/dev/null 2>err)
ret=$?
-test -f err || skip_ 'shell ulimit failure'
test $ret = 124 || {
fail=1
cat err
--
2.53.0