Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Another alias-related crash
- X-seq: zsh-workers 43511
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [BUG] Another alias-related crash
- Date: Fri, 21 Sep 2018 16:14:48 +0100
- 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==
- In-reply-to: <FF85A7CD-EA83-4B5A-A74C-310F2ED80DBB@dana.is>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <FF85A7CD-EA83-4B5A-A74C-310F2ED80DBB@dana.is>
On Thu, 20 Sep 2018 18:30:03 -0500
dana <dana@xxxxxxx> 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author