Subject: Re: /bin/sh crashing
To: Rhialto <rhialto@falu.nl>
From: Chavdar Ivanov <ci4ic4@gmail.com>
List: current-users
Date: 05/24/2007 16:36:14
On 24/05/07, Rhialto <rhialto@falu.nl> wrote:
> On Wed 23 May 2007 at 15:45:53 +0200, Jukka Salmi wrote:
> > Hi,
> >
> > the attached shell script crashes /bin/sh on NetBSD with a segfault,
> > at least with -current and 3.1_STABLE. However, if the script is
> > slightly modified - e.g. if the useless `if test 1' condition on line
> > 5 or the also useless `true;' on line 9 is removed - then running it
> > doesn't crash the shell. And, BTW, it doesn't crash ksh or bash...

You don't need the script to crash it -

 test ! $non-existent-var

is enough. Also see the following:

% /bin/sh
$ test ! $ABC
zsh: segmentation fault (core dumped)  /bin/sh
17:33 (ci~lisa)
% /bin/sh
$ test ! $ABCD
zsh: segmentation fault (core dumped)  /bin/sh
17:33 (ci~lisa)
% /bin/sh
$ test ! $ABCDE
$ test ! $ABCD
$ test ! $ABC
$ test ! $AB
$ test ! $A
$ test ! $ASDASDASDASDAD
$ ^D
%
17:34 (ci~lisa) /home/ci/Desktop
% /bin/sh
$ test ! $A
zsh: segmentation fault (core dumped)  /bin/sh

(longer than four characters don't seem to crash it; once it has gone
through success test, it does not crash further. weird).


>
> See http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=33960 for
> another case of sh crashing. The bug is still open (and assigned to the
> wrong person: the package maintainer does not maintain /bin/sh).
>
> It seems to be related to the "test" (or "[") builtin command too, at
> least there is one nearby.
>
> -Olaf.
> --
> ___ Olaf 'Rhialto' Seibert      -- You author it, and I'll reader it.
> \X/ rhialto/at/xs4all.nl        -- Cetero censeo "authored" delendum esse.
>

Chavdar Ivanov