Package: bash
Version: 4.1-3
Severity: normal

Attached is bashbug.sh which shows a strange bug in bash - with workaround.

The problem seems to be that certain redirections are not closed in-time,
leading to a possible exhaustion of file descriptors when doing this
redirection in a loop.

The strange thing about this is, that the file descriptors are closed
later, when it is already too late.

There is a workaround, this is to close the redirection manually.
However technically this is wrong, as at the time of the close the
redirection is no more in effect.

Possibly this is an upstream problem, I did not test it.

-- System Information:
Debian Release: 6.0.2
  APT prefers oldstable
  APT policy: (500, 'oldstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages bash depends on:
ii  base-files                6.0squeeze2    Debian base system miscellaneous f
ii  dash                      0.5.5.1-7.4    POSIX-compliant shell
ii  debianutils               3.4            Miscellaneous utilities specific t
ii  libc6                     2.11.2-10      Embedded GNU C Library: Shared lib
ii  libncurses5               5.7+20100313-5 shared libraries for terminal hand

Versions of packages bash recommends:
pn  bash-completion               <none>     (no description available)

Versions of packages bash suggests:
pn  bash-doc                      <none>     (no description available)

-- no debconf information

*** bashbug.sh
#!/bin/bash
#
# Out of file descriptors, because it forgets to close redirection

bug()
{
c=`ulimit -n`
let c+=100
while let c--
do
        while read -ru3 x
        do
                echo -n :
        done 3< <(echo x)

        # Workaround:
        # Explicite close of redirection
        $1 || exec 3<&-
done
}

works()
{
c=`ulimit -n`
let c+=100
while let c--
do
        while read -ru3 x
        do
                echo -n :
        done 3<<<"x"
done
}


echo "triggering bug"
bug true

echo "run with bug workaround"
bug false

echo "different redirection"
works



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to