Hi all,
Today I recompiled courier-authlib and this triggered the "bug": I got

/usr/local/sbin/imapd: xrealloc: ../bash/subst.c:512: cannot reallocate 512 bytes (0 bytes allocated)

same for imapd-ssl; the rest worked OK.

Note that /usr/local/sbin/imapd is a softlink to a shell script. If I invoke that script directly, I get the same result. However, if I _source_ it, it works.

Later on, I've made a copy of the script for testing. It turns out that execution stops when bash expands the command line that invokes /usr/bin/env. Replacing "/bin/sh" with "/bin/dash" on the shebang works. Thus, it is rather a bash extra memory consumption. You may play with the attached script to check when bash consumes more memory than allowed by its own ulimit. On the etch64 system I use, it stops either in subst.c or in make_cmd.c

Ciao
Ale
#! /bin/bash
# "reproduce" bug 393093

set -a

#     12345678901234567890123456789012345678901234567890
VAR1="this is variable is 50 bytes quote to quote length"
VAR2="$VAR1$VAR1$VAR1$VAR1$VAR1$VAR1$VAR1$VAR1$VAR1$VAR1"
VAR3="$VAR2$VAR2$VAR2$VAR2$VAR2$VAR2$VAR2$VAR2$VAR2$VAR2"
VAR4="$VAR3$VAR3$VAR3$VAR3$VAR3$VAR3$VAR3$VAR3$VAR3$VAR3"
VAR5="$VAR4$VAR4$VAR4$VAR4$VAR4$VAR4$VAR4$VAR4$VAR4$VAR4"
ulimit -v 65536
echo "VAR3 is 5000"
/bin/sh -c "echo "$VAR3" > /dev/null
echo "VAR4 is 50000"
/bin/sh -c "echo "$VAR4" > /dev/null
echo "not reached in bash"
echo "VAR5 is 500000"
/bin/sh -c "echo $VAR5" > /dev/null
echo "dash says: ./bstest: 19: /bin/sh: Argument list too long"

Reply via email to