zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.auc.dk
Subject: Re: ${(qP)${var}} causes core dump
Date: Sun, 09 Jan 2000 18:44:58 +0000	[thread overview]
Message-ID: <E127NIn-0001Pj-00.2000-01-09-18-42-57@mail11.svr.pol.co.uk> (raw)
In-Reply-To: "Tanaka Akira"'s message of "09 Jan 2000 17:25:46 +0900." <rsqln5z1wj9.fsf@crane.jaist.ac.jp>

Tanaka Akira wrote:
> zsh dumps core as follows.
> 
> Z(2):akr@is27e1u11% Src/zsh -f
> is27e1u11% var=a
> is27e1u11% a=(\* \*)
> is27e1u11% print -lr ${(qP)${var}}
> \*
> \*
> is27e1u11% print -lr ${(qP)${var}}
> zsh: segmentation fault (core dumped)  Src/zsh -f

The problem seems to be that paramsubst() is setting `copied = 1' after
retrieving the inner expression.  However, the value is then fetched for
the resulting parameter name `a', and it's only at that point one should
take account of whether the value has been copied.  Hence it was
erroneously operating directly on the value stored in the array.

Note that you can actually get away with ${(qP)var}, because the shell has
already been told of the inner lookup.

The following is safe, but Sven can probably tell us if converting the
unconditional assignment to
  if (!aspar)
      copied = 1;
would be better.

Index: Src/subst.c
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Src/subst.c,v
retrieving revision 1.2
diff -u -r1.2 subst.c
--- Src/subst.c	1999/12/03 19:12:11	1.2
+++ Src/subst.c	2000/01/09 18:36:23
@@ -1022,7 +1022,6 @@
 	    aspar = 0;
 	} else if (aspar)
 	    idbeg = val;
-	copied = 1;
 	*s = sav;
 	while (INULL(*s))
 	    s++;

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


  reply	other threads:[~2000-01-09 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-09  8:25 Tanaka Akira
2000-01-09 18:44 ` Peter Stephenson [this message]
2000-01-10  9:44 Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E127NIn-0001Pj-00.2000-01-09-18-42-57@mail11.svr.pol.co.uk \
    --to=pws@pwstephenson.fsnet.co.uk \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).