Bug 172059 - All bash scripts hang when starting on real tty
Summary: All bash scripts hang when starting on real tty
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: 4
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
: 181809 431556 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-10-30 08:39 UTC by Nigel Horne
Modified: 2014-03-17 02:56 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-01-06 21:58:07 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Alok's old bash_profile that causes the bash scripts to hang on real tty (209 bytes, text/plain)
2005-11-07 21:25 UTC, Alok Saldanha
no flags Details
Patches unicode_start to use /bin/sh instead of /bin/bash (284 bytes, patch)
2007-11-09 10:19 UTC, Björn Gerhart
no flags Details | Diff

Description Nigel Horne 2005-10-30 08:39:02 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7

Description of problem:
Bash scripts hang, running "bash -x" shows that they are hanging running a command unicode_start

Version-Release number of selected component (if applicable):
bash-3.0-31

How reproducible:
Always

Steps to Reproduce:
1. Start X, but do not login
2. <ctrl-alt-f1>
3. login to terminal session as root
  Attempt to run any bash script

Actual Results:  Script didn't start

Expected Results:  script should have started

Additional info:

I attempted to capture the output using 'script' to submit here as evidentce but then the program ran fine, presumably because the output was a pty rather than a tty.

Comment 1 Alok Saldanha 2005-11-05 23:20:41 UTC
I have found this problem as well, with the same version of bash. I can run the script find in X, but not 
at all if I run from a real tty. However, by sshing in from another machine and then running bash from 
the local terminal, I was able to capture the following, showing recursive calls to unicode_start that 
presumably can cause crashes and hangs:

ps -jHu remote 
  PID  PGID   SID TTY          TIME CMD
26721 26718 26718 ?        00:00:00 sshd
26722 26722 26722 pts/1    00:00:00   bash
28493 28493 26722 pts/1    00:00:00     ps
 4422  4422  4422 tty3     00:00:01 bash
27758 27758  4422 tty3     00:00:00   bash
27775 27758  4422 tty3     00:00:00     unicode_start
27792 27758  4422 tty3     00:00:00       unicode_start
27809 27758  4422 tty3     00:00:00         unicode_start
27826 27758  4422 tty3     00:00:00           unicode_start
27843 27758  4422 tty3     00:00:00             unicode_start
27861 27758  4422 tty3     00:00:00               unicode_start
27878 27758  4422 tty3     00:00:00                 unicode_start
27895 27758  4422 tty3     00:00:00                   unicode_start
27912 27758  4422 tty3     00:00:00                     unicode_start
27929 27758  4422 tty3     00:00:00                       unicode_start
27946 27758  4422 tty3     00:00:00                         unicode_start
27963 27758  4422 tty3     00:00:00                           unicode_start
27980 27758  4422 tty3     00:00:00                             unicode_start
27997 27758  4422 tty3     00:00:00                               unicode_start
28014 27758  4422 tty3     00:00:00                                 unicode_start
28031 27758  4422 tty3     00:00:00                                   unicode_start
28048 27758  4422 tty3     00:00:00                                     unicode_start
28065 27758  4422 tty3     00:00:00                                       unicode_start
28082 27758  4422 tty3     00:00:00                                         unicode_start
28099 27758  4422 tty3     00:00:00                                           unicode_start
28116 27758  4422 tty3     00:00:00                                             unicode_start
28133 27758  4422 tty3     00:00:00                                               unicode_start
28150 27758  4422 tty3     00:00:00                                                 unicode_start
28167 27758  4422 tty3     00:00:00                                                   unicode_star
28184 27758  4422 tty3     00:00:00                                                     unicode_st
28201 27758  4422 tty3     00:00:00                                                       unicode_
28218 27758  4422 tty3     00:00:00                                                         unicod
28235 27758  4422 tty3     00:00:00                                                           unic
28252 27758  4422 tty3     00:00:00                                                             un
28269 27758  4422 tty3     00:00:00                                                               
28286 27758  4422 tty3     00:00:00                                                               
28303 27758  4422 tty3     00:00:00                                                               
28320 27758  4422 tty3     00:00:00                                                               
28337 27758  4422 tty3     00:00:00                                                               
28354 27758  4422 tty3     00:00:00                                                               
28371 27758  4422 tty3     00:00:00                                                               
28388 27758  4422 tty3     00:00:00                                                               
28405 27758  4422 tty3     00:00:00                                                               
28422 27758  4422 tty3     00:00:00                                                               
28439 27758  4422 tty3     00:00:00                                                               
28456 27758  4422 tty3     00:00:00                                                               
28473 27758  4422 tty3     00:00:00                                                               
28490 27758  4422 tty3     00:00:00                                                               



Comment 2 Alok Saldanha 2005-11-05 23:24:39 UTC
Incidentally, should this affect bash scripts run as cron jobs? My computer has been uncharacteristically 
unstable recently, and it could be hanging because of thosands of unicode_start processes.


Comment 3 Tim Waugh 2005-11-07 09:35:06 UTC
unicode_start is called by /etc/profile.d/lang.* -- files which are owned by the
initscripts package.  Reassigning.

Comment 4 Bill Nottingham 2005-11-07 19:35:52 UTC
Interesting. What version of initscripts, setup, and kbd do you have installed,
and what does your /etc/sysconfig/i18n look like?

What does 'rpm -V initscripts setup kbd' look like?

Do you have any custom .bashrc or .bash_login files?

Comment 5 Nigel Horne 2005-11-07 21:21:55 UTC
[njh@njh ~]$ cat /etc/sysconfig/i18n
LANG="en_GB.UTF-8"
SYSFONT="latarcyrheb-sun16"
SUPPORTED="en_GB.UTF-8:en_GB:en"
[njh@njh ~]$ rpm -V initscripts setup kbd
..5....T  c /etc/inittab
S.5....T  c /etc/rc.d/rc.local
S.5....T  c /etc/sysctl.conf
.......T    /usr/share/locale/eu_ES/LC_MESSAGES/initscripts.mo
.......T    /usr/share/locale/sr/LC_MESSAGES/initscripts.mo
.......T    /usr/share/locale/ur/LC_MESSAGES/initscripts.mo
S.5....T  c /etc/aliases
..?.....  c /etc/environment
S.5....T  c /etc/printcap
..?.....  c /etc/securetty
.......T  c /etc/pam.d/kbdrate
[njh@njh ~]$
[njh@njh ~]$ cat .bash_login
cat: .bash_login: No such file or directory
[njh@njh ~]$ cat .bashrc
# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# 686 for Sharon/Laptop/Sian, 586 for gateway, 786 for NJH (doesn't work)
# -mfpmath=sse,387(gcc3) -msse2 -msse -mmmx for NJH (gcc3), -m3dnow (gcc3.3),
-msse for vmware
# -mmmx for GATEWAY (gcc3)
# -msse for SIAN (gcc3)
# -mcpu=7450 -maltivec -mabi=altivec for MAC
export CFLAGS="`curl-config --cflags` -O2 -W -Wformat=2 -Wswitch -Wshadow
-Wwrite-strings -Wuninitialized -Wwrite-strings -Wall -pipe -mtune=pentium4
-march=pentium4 -fomit-frame-pointer -ffast-math -msse2 -msse -mmmx -mfpmath=sse
-pedantic  -D_FORTIFY_SOURCE=2"
# export CFLAGS="-g -pg `curl-config --cflags` -O2 -Wformat=2 -Wswitch -Wshadow
-Wwrite-strings -Wuninitialized -Wall -pipe -mtune=pentium4 -march=pentium4
-ffast-math -msse2 -msse -mmmx -mfpmath=sse"
CXXFLAGS=$CFLAGS export CXXFLAGS
CPPFLAGS=$CFLAGS export CPPFLAGS
export LDFLAGS="`curl-config --libs`"
# export LDFLAGS="`curl-config --libs` -g -pg"

# export CFLAGS="-O2 -tpp7 -xWN -ipo -parallel -i_dynamic -w2 -march=pentium4
-mcpu=pentium4"
# export LDFLAGS=-i_dynamic
# export CC=icc
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel_cc_80/lib

# use --disable-shared to configure scripts
# export GCC_HOME=$HOME/build_3.2.2_dir/gcc
# export CC=$GCC_HOME/xgcc
# export CXX=$GCC_HOME/xgcc
# export CFLAGS="`curl-config --cflags` -g -fbounds-checking -O2 -Wuninitialized
-Wall -pipe -mtune=pentium4 -march=pentium4 -ffast-math -B$GCC_HOME/ -msse2
-msse -mmmx -mfpmath=sse"
# export LDFLAGS="`curl-config --libs` -L$GCC_HOME -fbounds-checking -B$GCC_HOME/"
# For masochists
# export GCC_BOUNDS_OPTS="-never-fatal -print-heap"

# export DISTCC_HOSTS='localhost/1 gateway'
# export CC=distcc
export CXX=g++

add_to_path () {
    echo $PATH | \
        awk -v newPath="${1}" -F: 'BEGIN {found = 0;} END {exit !found} \
            { for (i=1; (i<=NF) && !found; ++i) found = ($i == newPath); }'
    if test $? -ne 0 ; then PATH=${PATH}:"${1}"; export PATH; fi
    }

add_to_path $HOME/bin
add_to_path /opt/IBMJava2-13/bin
add_to_path :
add_to_path /usr/local/bin

export QTDIR=/usr/lib/qt-3.3
export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$QTDIR/lib:/usr/X11R6/libexport
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel_cc_80/lib

# export
MANPATH=$MANPATH:/usr/local/man:$HOME/man:/usr/share/coas/man:/usr/share/inn/man:/usr/share/perl5/man:/usr/share/tcl-8.0/man:/usr/share/tclX-8.0.4/man:/usr/share/tix-4.1/man:/usr/share/tk-8.0/man:/usr/server/doc
export
MANPATH=$MANPATH:/usr/local/man:$HOME/man:/usr/share/inn/man:/usr/share/perl5/man:/usr/share/tcl-8.0/man:/usr/share/tclX-8.0.4/man:/usr/share/tix-4.1/man:/usr/share/tk-8.0/man:/usr/server/doc:/usr/share/man

tty -s
if [ $? -eq 0 ]; then
        stty tab0 onocr erase '^?'
        set -o vi
        export EDITOR=gvim

        # xset fp+ unix/:7101
fi

NNTPSERVER=usenet.force9.net
export DBROOT DBWORK DBCONFIG PATH LD_LIBRARY_PATH NNTPSERVER

export INTEL_LICENSE_FILE=/opt/intel/licenses

export KDEDIR=$KDEDIR:/usr/local/kde

eval `removedups MANPATH LD_LIBRARY_PATH PATH KDEDIR`

export http_proxy=http://192.168.1.1:3128
export no_proxy=localhost
export ftp_proxy=http://192.168.1.1:3128

export CVS_RSH=ssh
export MALLOC_CHECK_=2
[njh@njh ~]$


Comment 6 Alok Saldanha 2005-11-07 21:23:53 UTC
Thanks for suggesting the startup scripts. I upgraded my system and copied over the user folders to /
home, so most of my regular users, although not root, have .bash_profile files from earlier versions of 
redhat. 
I was able to fix the problem by copying over the .bash_profile from the root. I will attach my 
old .bash_profile so you can try to replicate the problem. Put it in a regular user's home folder, log out, 
log in again, and then try running bash. Here's the rpm stuff since you asked:

 rpm -V initscripts setup kbd
..5....T. c /etc/inittab
..?...... c /etc/environment
........C c /etc/group
........C c /etc/passwd
S.5....T. c /etc/printcap
..?...... c /etc/securetty



Comment 7 Alok Saldanha 2005-11-07 21:25:05 UTC
Created attachment 120794 [details]
Alok's old bash_profile that causes the bash scripts to hang on real tty

Comment 8 Bill Nottingham 2005-11-07 21:37:38 UTC
Hm, the attachment in comment #7 works for me.

What /etc/profile.d scripts do you have?

Comment 9 Bill Nottingham 2005-11-07 21:40:48 UTC
Oh, wait, I see.
...
BASH_ENV=$HOME/.bashrc
USERNAME=""

export USERNAME BASH_ENV PATH
...

You don't want that as BASH_ENV; otherwise you'll get an infinite loop.

Comment 10 Alok Saldanha 2005-11-07 21:42:34 UTC
I haven't played around with them at all:

ls -la /etc/profile.d/
total 140
drwxr-xr-x   2 root root 4096 Oct 16 11:25 .
drwxr-xr-x  80 root root 8192 Nov  7 11:54 ..
-rwxr-xr-x   1 root root  764 Jul 25 08:39 colorls.csh
-rwxr-xr-x   1 root root  713 Jul 25 08:39 colorls.sh
-rwxr-xr-x   1 root root  192 Sep  1 12:06 glib2.csh
-rwxr-xr-x   1 root root  190 Sep  1 12:06 glib2.sh
-rwxr-xr-x   1 root root   58 Sep  7 06:52 gnome-ssh-askpass.csh
-rwxr-xr-x   1 root root   70 Sep  7 06:52 gnome-ssh-askpass.sh
-rwxr-xr-x   1 root root  218 Jun 29 19:50 krb5.csh
-rwxr-xr-x   1 root root  210 Jun 29 19:50 krb5.sh
-rwxr-xr-x   1 root root 2182 May 25 09:52 lang.csh
-rwxr-xr-x   1 root root 2470 May 25 09:52 lang.sh
-rwxr-xr-x   1 root root  122 Mar  4  2005 less.csh
-rwxr-xr-x   1 root root  108 Mar  4  2005 less.sh
-rwxr-xr-x   1 root root   77 Aug 10 07:35 vim.csh
-rwxr-xr-x   1 root root  246 Aug 10 07:35 vim.sh
-rwxr-xr-x   1 root root  170 Mar  7  2005 which-2.sh

Comment 11 Alok Saldanha 2005-11-07 21:45:29 UTC
oops, just got your post. I'm still not sure

1) why the old .bash_profile seemed to work for you
2) why it seems to work in an xterm, but not from the tty
3) if it's obviously flawed, why was it the default for an older redhat? did something change?

Although I don't really care, since my system works again.


Comment 12 Bill Nottingham 2005-11-07 21:47:53 UTC
From the bash man page:

When bash is started non-interactively, to run a shell script, for example, it
looks for the variable BASH_ENV in the environment... Bash behaves as if the
following command were executed:
  if [ -n "$BASH_ENV" ]; then . "$BASH_ENV" ;fi

So, if you set this, then, when you run unicode_start (for example), bash will
run ~/.bashrc, which sources /etc/bashrc, which sources /etc/profile.d/*.sh,
which then runs unicode_start (from lang.sh), which then runs ~/.bashrc... etc.
(less, with lessopen.sh, will show the same thing.)

Nigel, I'm sorry - I misspoke - do you have a .bash_profile (not .bash_login)
that sets BASH_ENV?

Comment 13 Bill Nottingham 2005-11-07 21:48:37 UTC
(As to why the old .bash_profile 'worked for me' - it didn't, I spoke too soon. :) )

Comment 14 Nigel Horne 2005-11-08 21:28:03 UTC
Yes BASH_ENV was set. I used a standard template (IIRC it's a machine that used
to run older FC versions), so how come it wasn't caught on the update?

Comment 15 Bill Nottingham 2005-11-08 21:30:33 UTC
I'm not sure what you mean ; the templates in /etc/skel would change, but
there's no way to go through and edit a .bash_profile in everyone's home dir.

Comment 16 Nigel Horne 2005-11-21 09:46:50 UTC
I can confirm that removing the definition for BASH_ENV stops the loop.

Comment 17 Bill Nottingham 2006-01-06 21:58:07 UTC
Closing this; it seems to be a configuration issue w.r.t BASH_ENV.

Comment 18 Miloslav Trmač 2006-02-16 22:16:00 UTC
*** Bug 181809 has been marked as a duplicate of this bug. ***

Comment 19 Björn Gerhart 2007-11-09 10:19:28 UTC
Created attachment 252521 [details]
Patches unicode_start to use /bin/sh instead of /bin/bash

Patch is created for modifying kbd-1.12-10.fc4.1.src.rpm. It just modifies the
very first line of unicode_start to #!/bin/sh.
(see also following issue: https://issues.rpath.com/browse/RPL-255)

Comment 20 Bill Nottingham 2007-11-09 14:54:40 UTC
Bjoern - please refile against kbd. Thanks!

Comment 21 Björn Gerhart 2008-02-05 14:30:10 UTC
Refiled against kbd:
*** Bug 172059 has been marked as a duplicate of this bug. ***

Comment 22 Björn Gerhart 2008-02-05 14:55:27 UTC
Ooops, my above comment does not contain the correct Bug id:

Refiled against kbd
*** Bug 431556 has been marked as a duplicate of this bug. ***


Comment 23 Björn Gerhart 2008-02-05 14:56:51 UTC
*** Bug 431556 has been marked as a duplicate of this bug. ***


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