From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20660 invoked by alias); 25 Mar 2010 13:06:17 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27827 Received: (qmail 19815 invoked from network); 25 Mar 2010 13:06:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Thu, 25 Mar 2010 13:06:01 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Infinite loop in parsing <()? Message-ID: <20100325130601.1ad26f05@news01> In-Reply-To: <87d3yszm3n.fsf@gmail.com> References: <87ljdhzijx.fsf@gmail.com> <100324173337.ZM25554@torch.brasslantern.com> <87d3yszm3n.fsf@gmail.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 Mar 2010 13:06:01.0429 (UTC) FILETIME=[EB1E3850:01CACC1B] X-Scanned-By: MailControl A_09_30_00 (www.mailcontrol.com) on 10.71.0.135 On Thu, 25 Mar 2010 12:17:48 +0100 Christian Neukirchen wrote: > Bart Schaefer writes: > > > On Mar 24, 7:22pm, Christian Neukirchen wrote: > > } > > } % cat <(echo foo | sort) > > } # 100% CPU usage > > > > My guess would be that you have an alias for "sort" ...? > > Whoops, right: > sort='LC_ALL=C sort' > > % cat <(echo foo | LC_ALL=C sort) > > works in zsh -f, but not with the alias set. Yes, that's 100% reproducible. Took a little hunting down. This is a local diff since CVS is a bit slow. --- Src/input.c 2010-01-18 10:17:49.000000000 +0000 +++ ../zsh-debug/zsh/Src/input.c 2010-03-25 12:58:04.000000000 +0000 @@ -195,21 +195,24 @@ return lastc; } - /* If the next element down the input stack is a continuation of - * this, use it. - */ - if (inbufflags & INP_CONT) { - inpoptop(); - continue; - } /* - * Otherwise, see if we have reached the end of input + * See if we have reached the end of input * (due to an error, or to reading from a single string). + * Check the remaining characters left, since if there aren't + * any we don't want to pop the stack---it'll mark any aliases + * as not in use before we've finished processing. */ - if (strin || errflag) { + if (!inbufct && (strin || errflag)) { lexstop = 1; return ' '; } + /* If the next element down the input stack is a continuation of + * this, use it. + */ + if (inbufflags & INP_CONT) { + inpoptop(); + continue; + } /* As a last resort, get some more input */ if (inputline()) return ' '; --- Test/A02alias.ztst 2009-03-03 17:08:12.000000000 +0000 +++ ../zsh-debug/zsh/Test/A02alias.ztst 2010-03-25 13:00:07.000000000 +0000 @@ -36,3 +36,9 @@ >Without >This command has the argument true >With + + print -u $ZTST_fd 'This test hangs the shell when it fails...' + alias sort='LC_ALL=C sort' + cat <(echo foo | sort) +0:Alias expansion works at the end of parsed strings +>foo -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom