Bug 179947

Summary: endless loop caused by #!/bin/bash and BASH_ENV=~/.bashrc
Product: [Fedora] Fedora Reporter: Lidwien Engel-Ligtvoet <bugzilla.20.lidwien>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED DUPLICATE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 4CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-02-04 01:52:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lidwien Engel-Ligtvoet 2006-02-04 00:07:05 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7

Description of problem:
After starting Vim on a console (/dev/tty2), inside of Vim I wanted to execute a command and then go to a subshell, using ":!time pwd" and ":sh".  Both times my commands were unresponsive until I hit ctrl-C.  I wanted to know what was going on, so I logged in on /dev/tty3 and started "top".  Then I started  :sh  inside of Vim again on the other console, /dev/tty1.  After a minute I noticed sudden disc activity (the system had started swapping) and after two minutes I switched to /dev/tty3 and in "top" I saw lots of instances of "unicode_start",
disappearing within seconds, used swap space dropping fast, then used memory dropping fast.
I can easily have the system run out of swap space if I start :sh from within Vim, then do nothing except to wait for several more minutes.
My environment:
TERM=linux
LANG=en_US.UTF-8
SHELL=/bin/bash
BASH_ENV=$HOME/.bashrc

If I do ":!time pwd" from within Vim on the console, wait for the command to finish, see nothing happen, then after several minutes I switch to /dev/tty4 and switch back to the Vim session, I get to see this:
/home/a3

real    0m0.000s
user    0m0.000s
sys     0m0.000s

The same kind of thing happens on another (slower, less memory) computer with Fedora Core 4 when I do  :!ls -l  and after several minutes of waiting I get: 

        /etc/profile.d/lang.sh: line 64: /sbin/consoletype: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/less.sh: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/qt.sh: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/vim.sh: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/which-2.sh: Too many open files in system
        /bin/bash: /bin/unicode_start: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/less.sh: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/qt.sh: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/vim.sh: Too many open files in system
        /etc/bashrc: line 43: /etc/profile.d/which-2.sh: Too many open files in system
        /bin/bash: /bin/unicode_start: Too many open files in system
        etc. etc.


I tracked it down to this:
1. Vim starts a subshell by calling $SHELL (/bin/bash)

Version-Release number of selected component (if applicable):
initscripts-8.11.1-1

How reproducible:
Always

Steps to Reproduce:
1. Log in to two consoles, say /dev/tty2 and /dev/tty3, as an ordinary user.
2. ~/.bashrc should begin with if [ -f /etc/bashrc ]; then . /etc/bashrc; fi
3. Environment: 
TERM=linux
LANG=en_US.UTF-8
SHELL=/bin/bash
BASH_ENV=$HOME/.bashrc
4. Start Vim; from within Vim do :sh or some other shell command
5. Do nothing, just watch the system run out of swap space after several minutes

Actual Results:  The system ran out of swap space.


Expected Results:  The system shouldn't run out of swap space.

The problem can be fixed by changing "#!/bin/bash" into "#!/bin/sh" in /bin/unicode_start.

Additional info:

If you change the first line of /bin/unicode_start from "#!/bin/bash" to "#!/bin/sh" then the problem disappears!

The problem can also be reproduced as follows:

cat > /tmp/testing
        export TERM=linux
        export LANG=en_US.UTF-8
        export SHELL=/bin/bash
        echo . /etc/bashrc > /tmp/loops
        chmod +x /tmp/loops
        export BASH_ENV=/tmp/loops
        . /tmp/loops
[ctrl-D]

Then, on a console (e.g. /dev/tty2), execute the command:
        sh /tmp/testing
and wait for several minutes doing nothing...

Comment 1 Miloslav Trmač 2006-02-04 01:52:54 UTC

*** This bug has been marked as a duplicate of 179949 ***