Subject: Re: /bin/sh crashing
To: None <current-users@netbsd.org>
From: Jukka Salmi <j+nbsd@2007.salmi.ch>
List: current-users
Date: 05/24/2007 19:09:16
Chavdar Ivanov --> current-users (2007-05-24 16:36:14 +0100):
>> 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).

I can't reproduce this (tried on -current and 3.1_STABLE):

$ /bin/sh
$ test ! $A
$ echo $?
0
$ 

Hmm...


Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~