Acknowledgement sent
to Valentin Hilbig <debian-bug-reply@03.softkill.org>:
New Bug report received and forwarded. Copy sent to Matthias Klose <doko@debian.org>.
(Fri, 23 Sep 2011 06:30:04 GMT) (full text, mbox, link).
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: bash: file number exhaustion on certain redirections in loop: "Too many open
files"
Date: Fri, 23 Sep 2011 08:22:35 +0200
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
Information forwarded
to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>: Bug#642504; Package bash.
(Fri, 26 Apr 2024 18:57:02 GMT) (full text, mbox, link).
Acknowledgement sent
to Antoine Beaupré <anarcat@debian.org>:
Extra info received and forwarded to list. Copy sent to Matthias Klose <doko@debian.org>.
(Fri, 26 Apr 2024 18:57:02 GMT) (full text, mbox, link).
To: Valentin Hilbig <debian-bug-reply@03.softkill.org>, 642504@bugs.debian.org
Subject: Re: Bug#642504: bash: file number exhaustion on certain
redirections in loop: "Too many open files"
Date: Fri, 26 Apr 2024 14:47:29 -0400
I saw a similar crash here, where bash would start failing around about
500 iterations in such a loop:
```
export GIT_ASKPASS=echo
grep -v '^#' ../gitolite2gitlab.txt |while read gitolite_path gitlab_path; do
gitolite_url=/srv/git.torproject.org/repositories/$gitolite_path.git
gitlab_url=https://gitlab.torproject.org/$gitlab_path.git
echo "diff -u $gitolite_url $gitlab_url"
diff -u <(git ls-remote $gitolite_url) <(git ls-remote $gitlab_url)
done | tee final-remote-diff.patch
```
~500 is not a random number. it's about half of 1024, which i suspect is
the fd limit i'm hitting. i'm betting the shell is just not closing
those file descriptor at all after the pipeline completes.
normally, i would expect the FD to close after the `diff -u` command
returns there, but it seems that's just not happening.
Marked as found in versions bash/5.2.21-2.
Request was from Gioele Barabucci <gioele@svario.it>
to control@bugs.debian.org.
(Sat, 27 Apr 2024 12:00:05 GMT) (full text, mbox, link).
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.