zsh-workers
 help / color / mirror / code / Atom feed
* zsh bug-hang on startup after exec
@ 2001-03-21 21:25 Ryan Richter
  2001-03-22  1:01 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Richter @ 2001-03-21 21:25 UTC (permalink / raw)
  To: zsh-workers

I had been using bash as my login shell, and had it set up to exec zsh.  I just
upgraded zsh from 3.1.6 to 3.1.9, and when I log in, zsh hangs immediately
after being execed, before it even processes the startup scripts.  This does
not happen if bash just runs zsh instead of execing it, and it no longer
happens now that zsh is my login shell.  Also it does not happen if I run bash
interactively and exec zsh.

Fortunately(?) the hanging behavior persisted when I had bash do:
exec strace zsh 2>strace.out
Here are the results:

execve("/usr/local/bin/zsh", ["zsh"], [/* 21 vars */]) = 0
brk(0)                                  = 0x80af778
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40014000
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_ISGID|S_ISVTX|0464, st_size=0, ...}) = 0
mmap(0, 27685, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40015000
close(3)                                = 0
open("/lib/libdl.so.2", O_RDONLY)       = 3
fstat(3, {st_mode=0, st_size=0, ...})   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 12428, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4001c000
mprotect(0x4001e000, 4236, PROT_NONE)   = 0
mmap(0x4001e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1000)
= 0x4001e000
close(3)                                = 0
open("/lib/libnsl.so.1", O_RDONLY)      = 3
fstat(3, {st_mode=0, st_size=0, ...})   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 88104, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40020000
mprotect(0x40032000, 14376, PROT_NONE)  = 0
mmap(0x40032000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x11000)
= 0x40032000
mmap(0x40034000, 6184, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) =
 0x40034000
close(3)                                = 0
open("/lib/libtermcap.so.2", O_RDONLY)  = 3
fstat(3, {st_mode=0, st_size=0, ...})   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 12520, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40036000
mprotect(0x40038000, 4328, PROT_NONE)   = 0
mmap(0x40038000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1000)
= 0x40038000
close(3)                                = 0
open("/lib/libm.so.6", O_RDONLY)        = 3
fstat(3, {st_mode=0, st_size=0, ...})   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 117208, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4003a000
mprotect(0x40056000, 2520, PROT_NONE)   = 0
mmap(0x40056000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1b000)
= 0x40056000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
fstat(3, {st_mode=0, st_size=0, ...})   = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40057000
mmap(0, 1001532, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40058000
mprotect(0x40145000, 30780, PROT_NONE)  = 0
mmap(0x40145000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0xec000) = 0x40145000
mmap(0x40149000, 14396, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) 
= 0x40149000
close(3)                                = 0
mprotect(0x40058000, 970752, PROT_READ|PROT_WRITE) = 0
mprotect(0x40058000, 970752, PROT_READ|PROT_EXEC) = 0
munmap(0x40015000, 27685)               = 0
personality(0 /* PER_??? */)            = 0
getpid()                                = 20122
brk(0)                                  = 0x80af778
brk(0x80af7b0)                          = 0x80af7b0
brk(0x80b0000)                          = 0x80b0000
getuid()                                = 500
geteuid()                               = 500
getgid()                                = 500
getegid()                               = 500
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
brk(0x80b2000)                          = 0x80b2000
readlink("/proc/self/fd/0", "/dev/ttyp0", 4095) = 10
open("/dev/ttyp0", O_RDWR|O_NOCTTY|0x8000) = 3
fcntl(3, F_DUPFD, 10)                   = 10
close(3)                                = 0
fcntl(10, F_GETFL)                      = 0x8002 (flags O_RDWR|0x8000)
recvmsg(10, 0xbffff86c, 0x40148d40)     = -1 ENOSYS (Function not implemented)
fstat(10, {st_mode=S_ISVTX|0400, st_size=0, ...}) = 0
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40015000
ioctl(10, TCGETS, {B9600 opost isig icanon echo ...}) = 0
_llseek(0xa, 0, 0, 0xbffff8ac, 0x1)     = -1 ESPIPE (Illegal seek)
munmap(0x40015000, 4096)                = 0
ioctl(10, TCGETS, {B9600 opost isig icanon echo ...}) = 0
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0
SYS_175(0, 0xbffff96c, 0xbffff8ec, 0x8, 0) = 0
SYS_174(0x11, 0, 0xbffff6f0, 0x8, 0x11) = 0
SYS_175(0x2, 0xbffff8ec, 0, 0x8, 0x2)   = 0
nanosleep(0xbffff858, 0xbffff858, 0x401481cc, 0xbffff858, 0xbffff96c) = 0
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0
kill(-20120, SIGTTIN)                   = 0
--- SIGTTIN (Stopped (tty input)) ---
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0
SYS_175(0, 0xbffff96c, 0xbffff8ec, 0x8, 0) = 0
SYS_174(0x11, 0, 0xbffff6f0, 0x8, 0x11) = 0
SYS_175(0x2, 0xbffff8ec, 0, 0x8, 0x2)   = 0
nanosleep(0xbffff858, 0xbffff858, 0x401481cc, 0xbffff858, 0xbffff96c) = 0
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0
kill(-20120, SIGTTIN)                   = 0
--- SIGTTIN (Stopped (tty input)) ---
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0
SYS_175(0, 0xbffff96c, 0xbffff8ec, 0x8, 0) = 0
SYS_174(0x11, 0, 0xbffff6f0, 0x8, 0x11) = 0
SYS_175(0x2, 0xbffff8ec, 0, 0x8, 0x2)   = 0
nanosleep(0xbffff858, 0xbffff858, 0x401481cc, 0xbffff858, 0xbffff96c) = 0
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0
kill(-20120, SIGTTIN)                   = 0
--- SIGTTIN (Stopped (tty input)) ---

These last 10 lines (between getpgrp() and getting SIGTTIN) repeat ad
infinitum.  SYS_174 and SYS_175 are rt_sigaction and rt_sigprocmask
respectively (dunno why strace doesn't know that...).

Anyway, this is a linux 2.2.19 i686 system with glibc 2.1.3, and zsh was
compiled with egcs 1.1.2.

And thanks for the cool shell :)
-- 
Ryan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-21 21:25 zsh bug-hang on startup after exec Ryan Richter
@ 2001-03-22  1:01 ` Bart Schaefer
  2001-03-22  1:56   ` Ryan Richter
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2001-03-22  1:01 UTC (permalink / raw)
  To: bobort, zsh-workers

On Mar 21,  1:25pm, Ryan Richter wrote:
} Subject: zsh bug-hang on startup after exec
}
} I had been using bash as my login shell, and had it set up to exec
} zsh. I just upgraded zsh from 3.1.6 to 3.1.9, and when I log in, zsh
} hangs immediately after being execed, before it even processes the
} startup scripts.

The strace output shows that it's getting stuck in this loop in init.c:

            while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
                sleep(1);       /* give parent time to change pgrp */
                mypgrp = GETPGRP();
                if (mypgrp == mypid)
                    attachtty(mypgrp);
                if (mypgrp == gettygrp())
                    break;
                killpg(mypgrp, SIGTTIN);
                mypgrp = GETPGRP();
            }

Why zsh is not becoming the process group leader, I don't know.  Obviously
bash must be exec'ing it before making *itself* the process group leader,
but then who *is* the group leader, a?

Note that

getpid()                                = 20122
getpgrp()                               = 20120
ioctl(10, TIOCGPGRP, [20121])           = 0

So there are at least three processes involved here ... the process group
leader is 20120 (whatever that was), but the tty group leader is 20121,
and neither of those is zsh (20122), so (mypgrp == mypid) is never going
to be true.

} Anyway, this is a linux 2.2.19 i686 system with glibc 2.1.3, and zsh was
} compiled with egcs 1.1.2.

Why does everyone always identify their Linux system by kernel version and
glibc version?  That's almost never enough information.  The vendor (e.g.
redhat) and vendor's version number (e.g. 7.1) are almost always much more
useful.  In this case it'd also be nice to know how you're logging in; is
it on the text console?  Remote shell?  XDM console?  If the latter, are
you using vanilla XDM, KDE, Gnome, or something else?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-22  1:01 ` Bart Schaefer
@ 2001-03-22  1:56   ` Ryan Richter
  2001-03-22 16:56     ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Richter @ 2001-03-22  1:56 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers


On 22-Mar-2001 Bart Schaefer wrote:
> Why zsh is not becoming the process group leader, I don't know.  Obviously
> bash must be exec'ing it before making *itself* the process group leader,
> but then who *is* the group leader, a?
> 
> Note that
> 
> getpid()                                = 20122
> getpgrp()                               = 20120
> ioctl(10, TIOCGPGRP, [20121])           = 0
> 
> So there are at least three processes involved here ... the process group
> leader is 20120 (whatever that was), but the tty group leader is 20121,
> and neither of those is zsh (20122), so (mypgrp == mypid) is never going
> to be true.

I ran it again by doing 'su myself -c bash', and the process group leader is
su and the tty group leader is strace, which would originally have been bash. 

Did it again with bash just execing zsh and attached strace after zsh started. 
In this case the process group leader is su and the tty group leader is zsh.

> } Anyway, this is a linux 2.2.19 i686 system with glibc 2.1.3, and zsh was
> } compiled with egcs 1.1.2.
> 
> Why does everyone always identify their Linux system by kernel version and
> glibc version?  That's almost never enough information.  The vendor (e.g.
> redhat) and vendor's version number (e.g. 7.1) are almost always much more
> useful.  In this case it'd also be nice to know how you're logging in; is
> it on the text console?  Remote shell?  XDM console?  If the latter, are
> you using vanilla XDM, KDE, Gnome, or something else?

Well, this system started off as redhat 5.1, but it's probably best
approximated by redhat 6.2 at present.  I was logging in via the console and
with su.  I just tried logging in remotely via ssh and it didn't hang.
-- 
Ryan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-22  1:56   ` Ryan Richter
@ 2001-03-22 16:56     ` Bart Schaefer
  2001-03-22 17:02       ` Ryan Richter
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2001-03-22 16:56 UTC (permalink / raw)
  To: bobort; +Cc: zsh-workers

On Mar 21,  5:56pm, Ryan Richter wrote:
} Subject: Re: zsh bug-hang on startup after exec
}
} I ran it again by doing 'su myself -c bash', and the process group
} leader is su and the tty group leader is strace, which would
} originally have been bash.
} 
} Did it again with bash just execing zsh and attached strace after zsh
} started. In this case the process group leader is su and the tty group
} leader is zsh.

[...]

} ... best approximated by redhat 6.2 at present. I was logging in via
} the console and with su. I just tried logging in remotely via ssh and
} it didn't hang.

OK.

When I try this on a RH6.2 system I get process group and tty group
leaders the same, even though neither of them is the same as zsh's PID.
That causes zsh to exit the loop, even though it has never attachtty()d.

What we (zsh-workers) need to find out is whether what you see instead
is a normal behavior of some new version of su/bash/whatever, or whether
it is an anomaly of your system (which at the moment I'm at a loss to
explain).

Please tell us the RPM version numbers of these packages on your system:

bash
sh-utils
util-linux

Thanks.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-22 16:56     ` Bart Schaefer
@ 2001-03-22 17:02       ` Ryan Richter
  2001-03-25 21:07         ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Richter @ 2001-03-22 17:02 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers


On 22-Mar-2001 Bart Schaefer wrote:
> When I try this on a RH6.2 system I get process group and tty group
> leaders the same, even though neither of them is the same as zsh's PID.
> That causes zsh to exit the loop, even though it has never attachtty()d.
> 
> What we (zsh-workers) need to find out is whether what you see instead
> is a normal behavior of some new version of su/bash/whatever, or whether
> it is an anomaly of your system (which at the moment I'm at a loss to
> explain).
> 
> Please tell us the RPM version numbers of these packages on your system:
> 
> bash
> sh-utils
> util-linux

I have bash-2.02.1-2, sh-utils-1.16-12, and util-linux-2.10f-7.
-- 
Ryan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-22 17:02       ` Ryan Richter
@ 2001-03-25 21:07         ` Bart Schaefer
  2001-03-25 22:34           ` Ryan Richter
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2001-03-25 21:07 UTC (permalink / raw)
  To: bobort; +Cc: zsh-workers

On Mar 22,  9:02am, Ryan Richter wrote:
} Subject: Re: zsh bug-hang on startup after exec
}
} I have bash-2.02.1-2, sh-utils-1.16-12, and util-linux-2.10f-7.

Hrm.  I'm unable to reproduce the hang with any of the following:

(RedHat 5.1 with miscellaneous upgrades to approximate 5.2)

bash-1.14.7-11
sh-utils-1.16-14
util-linux-2.7-18

(RedHat 5.2 with miscellaneous upgrades)

bash-1.14.7-13
sh-utils-1.16-14
util-linux-2.8-11

(RedHat 6.2 with most of the latest upgrades)

bash-1.14.7-23.6x
sh-utils-2.0-5
util-linux-2.10f-7

So perhaps it's related to bash-2.02.1-2.  I don't find that RPM on
rpmfind.net for anything but sparc.  Are you running linux on a sparc?
Where did you come by that RPM?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-25 21:07         ` Bart Schaefer
@ 2001-03-25 22:34           ` Ryan Richter
  2001-03-28  5:48             ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Richter @ 2001-03-25 22:34 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers


On 25-Mar-2001 Bart Schaefer wrote:
> So perhaps it's related to bash-2.02.1-2.  I don't find that RPM on
> rpmfind.net for anything but sparc.  Are you running linux on a sparc?
> Where did you come by that RPM?
> 

Sorry, I lied about the bash version.  While I do have that rpm installed, I
compiled a newer bash release from source since then.  From bash --version:
GNU bash, version 2.03.0(1)-release (i686-pc-linux-gnu)

I'm fairly certain that pub/gnu/bash/bash-2.03.tar.gz on ftp.gnu.org is the
version I've got.
-- 
Ryan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: zsh bug-hang on startup after exec
  2001-03-25 22:34           ` Ryan Richter
@ 2001-03-28  5:48             ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2001-03-28  5:48 UTC (permalink / raw)
  To: zsh-workers

On Mar 25,  2:34pm, Ryan Richter wrote:
} Subject: Re: zsh bug-hang on startup after exec
}
} Sorry, I lied about the bash version. While I do have that rpm
} installed, I compiled a newer bash release from source since
} then. From bash --version: GNU bash, version 2.03.0(1)-release
} (i686-pc-linux-gnu)

I just upgraded the OS on one of the machines at work, so I was able to set
my shell to:

GNU bash, version 2.03.8(1)-release (i386-redhat-linux-gnu)

Then I put "exec /bin/zsh" in both .bashrc and .bash_profile (because for
some reason, although the doc says that "all interactive shells" will read
the ~/.bashrc file, login shells do not).

I still wasn't able to reproduce the problem.

However, it's bad form to have a potentially infinite loop in the shell
startup.  Zsh should probably just give up after either some number of
loops or some length of time.  Anyone have a suggestion?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-03-28  5:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-21 21:25 zsh bug-hang on startup after exec Ryan Richter
2001-03-22  1:01 ` Bart Schaefer
2001-03-22  1:56   ` Ryan Richter
2001-03-22 16:56     ` Bart Schaefer
2001-03-22 17:02       ` Ryan Richter
2001-03-25 21:07         ` Bart Schaefer
2001-03-25 22:34           ` Ryan Richter
2001-03-28  5:48             ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).