Bug 179947 - endless loop caused by #!/bin/bash and BASH_ENV=~/.bashrc
Summary: endless loop caused by #!/bin/bash and BASH_ENV=~/.bashrc
Keywords:
Status: CLOSED DUPLICATE of bug 179949
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: 4
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-02-04 00:07 UTC by Lidwien Engel-Ligtvoet
Modified: 2014-03-17 02:58 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-02-04 01:52:54 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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 ***


Note You need to log in before you can comment on or make changes to this bug.