From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43511-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 3760ea61 for ; Fri, 21 Sep 2018 15:26:53 +0000 (UTC) Received: (qmail 21556 invoked by alias); 21 Sep 2018 15:26:36 -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: List-Unsubscribe: X-Seq: 43511 Received: (qmail 19837 invoked by uid 1010); 21 Sep 2018 15:26:36 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-11.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.75):SA:0(-1.9/5.0):. Processed in 4.20184 secs); 21 Sep 2018 15:26:36 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [92.27.217.10] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=EPmyLGRC c=1 sm=1 tr=0 a=8ZNYBr2XW9PeDhz77hzA2g==:117 a=8ZNYBr2XW9PeDhz77hzA2g==:17 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=RfIwOu1XTbvel5nLhBAA:9 a=CjuIK1q_8ugA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1537542892; bh=EJ9XRPLyucl+E3E9Gi20anromYmuIuYK0W9oCp1aBmk=; h=Date:From:To:Subject:In-Reply-To:References; b=0oaoZ1tDg3OwBhPxSVpQH4JxfN+zaK4S1uBcMq+GP4SR4Otztg3ZhEp/hqVimTkpd HmqsqgEdZpEnqUFd0xZWImZMKjNEgq7TEwoBokmDwZ3Et7yRNfIO+MExCzuR/RHbuM /yJ+nd23kjXXSz76Nul2WDhn+ov5q1zcGxkmpB6h99PPbuxKGN/loWeG7JyNV9zGKC qQORmvtYFMMNu9XpC4WG8nC611z5T6O+gW2UrCMviOjzbtS+R6Y/YPZyLKlU4YN/NS TfZZPOrsXQFnZyi+RWqbDPKbffoSGtV/t/VsKF6tBYfLQyPWDCkGDVRzTq8VUQYLfX 1UXYwNjoqYpsg== Date: Fri, 21 Sep 2018 16:14:48 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: [BUG] Another alias-related crash Message-ID: <20180921161448.13b5b94a@pws-HP.localdomain> In-Reply-To: References: X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfOEM1VJfH8BbDOJKuwZZYvjwyVPVPbzv7nYpjP2nyE/7vQ9O3bImHnInD4tgrBqyV2CXLsmqvP2W3b4D9jaq8sAuhehmssBlOJ3+dPnLR6F8kZCwxVd1 ZjtkgozKBYeL8fO6EfFq22Rn4mmXu8oDTVmwmlVNF3zn75XaXaBryaI3ZOM6yakW6uNItHGJQXhOxA== On Thu, 20 Sep 2018 18:30:03 -0500 dana wrote: > # Crash > % alias grep='grep --color=auto' > % echo $(( $(echo x | grep . )) > zsh: segmentation fault I'm not getting a crash but valgrind does show a problem. It suggests this simple patch fixes it. The DPUTS is just a paranoid check which isn't relevant to the crash here; these are all compiled out unless you have a debug buid. This code is particularly complicated owing to having to decide between $(( $(echo stuff) )) --- mathematical evaluation --- and $(( $(echo stuff)); more stuff) --- command substitution with a subshell inside, which as far as I can see is valid syntax. Although the alias bug isn't directly related, I think it shows up here because of the particularly active use of the input stack while the shell is deciding what's going on. Would strongly advise NOT doing completion in that sort of code. The resulting bus smash of hard to understand bits of the shell could make the quantum vacuum unstable. (Sort of "off mass shell". Physicists' joke, sort of.) pws diff --git a/Src/input.c b/Src/input.c index 9787dedf6..e9989ffe4 100644 --- a/Src/input.c +++ b/Src/input.c @@ -555,6 +555,7 @@ inpush(char *str, int flags, Alias inalias) if ((instacktop->alias = inalias)) inalias->inuse = 1; } else { + instacktop->alias = NULL; /* If we are continuing an alias expansion, record the alias * expansion in new set of flags (do we need this?) */ @@ -691,6 +692,7 @@ char *input_hasalias(void) { if (!(flags & INP_CONT)) break; + DPUTS(instackptr == instack, "BUG: continuation at bottom of instack"); instackptr--; if (instackptr->alias) return instackptr->alias->node.nam;