From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9288 invoked by alias); 2 Nov 2009 21:06:58 -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: 27337 Received: (qmail 15870 invoked from network); 2 Nov 2009 21:06:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.219.207 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=SG57YuNaxwr6H78Tc3VwiUOKwYcu6xoCbdG5vvKpg/Y=; b=O+h9Fp0ynfRp0nO+eZUjH8gAqMog4F3HCSs4WE0+MdECp/oWyMGajdC7SE2jgkXTFW P+XuzUz/X59jm3cO1kdy3DIdVnzs36qD/7pDzusxop4Qx+Y8qLK5IpSCYqFTOdJtlQsy nBpEhu87en8zQbv1p0/cdYDxmNs/yBgCDR2EA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=unB4izHhe28/lbNsmCrWXU5nk2nLQLAVo0OipUYI4ZKlu2X4MywLzy/rSVixsop1Qi vYmrg1InGd9l3m5memErtqU5ttzZ0BwCElG7FxY6HqWTRenB0bWu5lBbeLHex5A/O5By qyLesCyl/8ZoJ6LZ+VnpI2OyRjtYSB92HSvEY= MIME-Version: 1.0 In-Reply-To: <237967ef0911021258x5403c976m281fb66ee7488b59@mail.gmail.com> References: <237967ef0911011312u307ecf19kbabf9fecf867cec1@mail.gmail.com> <200911012220.nA1MKgjM005270@pws-pc.ntlworld.com> <237967ef0911011657n54279c54ja8fce16a1861ff4f@mail.gmail.com> <237967ef0911011726q7550593ax30bc61f1a736e725@mail.gmail.com> <20091102163858.11415153@news01> <237967ef0911021258x5403c976m281fb66ee7488b59@mail.gmail.com> Date: Mon, 2 Nov 2009 22:06:51 +0100 Message-ID: <237967ef0911021306y33467270l6a1cf921cefbe037@mail.gmail.com> Subject: Re: zsh eats 100% CPU with completion in / From: Mikael Magnusson To: Peter Stephenson Cc: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 2009/11/2 Mikael Magnusson : > Here we are, > > (gdb) watch lextok2['/'] > Hardware watchpoint 9: lextok2['/'] > Continuing. > Hardware watchpoint 9: lextok2['/'] > > Old value = 47 '/' > New value = 0 '\000' > 0x080c962f in xsymlinks (s=0x818e8f1 "..") at utils.c:696 > 696 *p = '\0'; > > (start over and add breakpoints (i'm not in reversible now just to be safe)) > > 692 if (!strcmp(xbuf, "/")) > (gdb) print xbuf > $22 = '\000' > (gdb) n > 694 p = xbuf + strlen(xbuf); > (gdb) > 695 while (*--p != '/'); > (gdb) n > at this point i pressed ctrl-c because i was curious what was taking > so long. Apparently this loops over all memory until it finds a slash, > which takes a while under gdb. Also apparently, the first / it finds > is in lextok2. And this seems to fix it. Not sure if checking that inside the loop is the best place, but there seems to be some freeing of *pp going on that I didn't feel like investigating. Maybe checking xbuf before slashsplit would work? diff --git a/Src/utils.c b/Src/utils.c index 2a05624..634edc5 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -691,6 +691,8 @@ xsymlinks(char *s) zsfree(*pp); if (!strcmp(xbuf, "/")) continue; + if (!*xbuf) + continue; p = xbuf + strlen(xbuf); while (*--p != '/'); *p = '\0'; -- Mikael Magnusson