Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall uname output: Linux cduffyxp 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 04:38:19 UTC 2010 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.0 Patch Level: 33 Release Status: release Description: File descriptor leak in nested functions Repeat-By: Run the following code: function get_fd_count() { local fds cd /proc/$$/fd; fds=( * ) # avoid a StackOverflow source colorizer bug echo "${#f...@]}" } function fd_leak_func() { echo ">> Current FDs: $(get_fd_count)" read retval new_state < <(set +e; new_state=$(echo foo); retval=$?; printf "%d %s\n" $retval $new_state) } function parent_func() { while fd_leak_func; do :; done } parent_func If the issue occurs, the "Current FDs" value constantly increases, eventually leading to exhaustion. Note that parent_func is essential; if the while loop is removed from the function and run at top level, the issue will not occur. This has also been observed against bash 3.2.25.