From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11475 invoked from network); 7 Oct 2004 17:56:35 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Oct 2004 17:56:35 -0000 Received: (qmail 47573 invoked from network); 7 Oct 2004 17:56:29 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Oct 2004 17:56:29 -0000 Received: (qmail 10573 invoked by alias); 7 Oct 2004 17:55:44 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8045 Received: (qmail 10560 invoked from network); 7 Oct 2004 17:55:43 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 7 Oct 2004 17:55:43 -0000 Received: (qmail 45984 invoked from network); 7 Oct 2004 17:55:06 -0000 Received: from proxy.vc-graz.ac.at (193.171.121.30) by a.mx.sunsite.dk with SMTP; 7 Oct 2004 17:55:04 -0000 Received: from localhost (b-55.vc-graz.ac.at [193.171.241.55]) by proxy.vc-graz.ac.at (8.12.11/8.12.11) with ESMTP id i97Ht28T027929 for ; Thu, 7 Oct 2004 19:55:02 +0200 (MEST) Date: Thu, 7 Oct 2004 19:55:03 +0200 From: Michael Prokop To: zsh-users@sunsite.dk Subject: Re: Using 'command -v' in a shellscript results in a coredump Message-ID: <2004-10-07T19-43-00@devnull.michael-prokop.at> Reply-To: Michael Prokop Mail-Followup-To: zsh-users@sunsite.dk References: <2004-08-19T01-13-05@devnull.michael-prokop.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-URL: http://www.michael-prokop.at/ X-Operating-System: Debian GNU/Linux - 2.6.8.1 on a i686 X-Registered-Linux-User: 224337 X-Crypto: GnuPG/1.2.3 http://www.gnupg.org X-GPG-Key-ID: 0x37E272E8 X-GPG-Key: http://www.michael-prokop.at/gpg X-GPG-Fingerprint: 04AE E62C 9502 CD34 A7DA 857B D8DF 53FB 37E2 72E8 User-Agent: Mutt/1.5.6i X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75c on proxy.vc-graz.ac.at X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 * Bart Schaefer [20040819 09:15]: > On Thu, 19 Aug 2004, Michael Prokop wrote: > > #!/bin/sh > > command -v blub > /dev/null 2>&1 > > Running it results in 'zsh: segmentation fault (core dumped)'. > The following prevents the core dump without producing any errors from > "make test", but I suspect there's something deeper that should be fixed > instead. > The crash happens whenever 'command -v' or 'command -V' is used with the > POSIXBUILTINS option set. > The problem is that the code in execcmd() near line 1848 assigns 'hn' to > point at the special 'commandbn' struct, but then 1952 is reached and > tries (again) to find the builtin named "command" which fails. Nothing > picks up the error after that and a null 'hn' is eventually dereferenced > by execbuiltin(). > Index: Src/exec.c > =================================================================== > RCS file: /cvsroot/zsh/zsh/Src/exec.c,v > retrieving revision 1.69 > diff -u -r1.69 exec.c > --- Src/exec.c 29 Jul 2004 15:09:51 -0000 1.69 > +++ Src/exec.c 19 Aug 2004 07:03:43 -0000 > @@ -1949,7 +1949,7 @@ > is_shfunc = 1; > break; > } > - if (!(hn = builtintab->getnode(builtintab, cmdarg))) { > + if (!hn && !(hn = builtintab->getnode(builtintab, cmdarg))) { > if (cflags & BINF_BUILTIN) { > zwarn("no such builtin: %s", cmdarg, 0); > lastval = 1; Thanks, Bart. (I'm replying with latency because I wanted to wait for any updates on this topic.) In the current CVS sources from zsh (2004-10-07) this bug isn't fixed AFAICS (refering to line 1978 of Src/exec.c). Some post-install scripts on Debian systems use 'command -v'. I'm using zsh as the '/bin/sh'-shell on my systems. When I'm upgrading the systems I often have to do a 'rm /bin/sh; ln -s /bin/bash /bin/sh' and point it back after process of upgrading to avoid the mentioned core dumps. Any chance to see this bug fixed in upcoming versions of zsh (with above code)? thx && regards, (-: Michael