From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10718 invoked from network); 15 Oct 2001 11:24:10 -0000 Received: from unknown (HELO sunsite.dk) (130.225.247.90) by ns1.primenet.com.au with SMTP; 15 Oct 2001 11:24:10 -0000 Received: (qmail 18227 invoked by alias); 15 Oct 2001 11:24:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16041 Received: (qmail 18212 invoked from network); 15 Oct 2001 11:24:04 -0000 From: Sven Wischnowsky MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15306.51026.58822.126859@gargle.gargle.HOWL> Date: Mon, 15 Oct 2001 13:24:02 +0200 To: zsh-workers@sunsite.dk Subject: Re: PATCH: Re: Very odd behaviour with zsh, maybe corruption bug In-Reply-To: <1011014215607.ZM6899@candle.brasslantern.com> References: <1011012050227.ZM19535@candle.brasslantern.com> <1011014215607.ZM6899@candle.brasslantern.com> X-Mailer: VM 6.92 under 21.1 (patch 3) "Acadia" XEmacs Lucid Bart Schaefer wrote: > On Oct 12, 5:02am, Bart Schaefer wrote: > } > } This *must* be a bug in prefork() called via singsub(); it must be zeroing > } `right' (and thus also zeroing `opat') before copying the string. But I > } just can't seem to catch it happening. > > Having traced through this more closely, which was rather laborious, I > have come to the conclusion that the bug is right there in evalcond(), > and that the following is the fix. At least, I can't see how this patch > could possibly cause -incorrect- behavior, though it might result in an > optimization being skipped unnecessarily in some cases. > > Sven, please dispute this if you can. > > ... > > - right = opat = dupstring(ecrawstr(state->prog, state->pc, > + right = dupstring(opat = ecrawstr(state->prog, state->pc, > &htok)); This is right. I hadn't realised that paramsubst() (called indirectly from singsub()) modifies the string it gets even though it gets a pointer (it's that `*s++ = '\0', I think). We need a similar fix in execcase(), below is a patch for both of these, which I will commit to both branches. Bye Sven Index: Src/cond.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/cond.c,v retrieving revision 1.2 diff -u -r1.2 cond.c --- Src/cond.c 2000/04/01 20:49:48 1.2 +++ Src/cond.c 2001/10/15 11:23:26 @@ -202,7 +202,7 @@ char *opat; int save; - right = opat = dupstring(ecrawstr(state->prog, state->pc, + right = dupstring(opat = ecrawstr(state->prog, state->pc, &htok)); if (htok) singsub(&right); Index: Src/loop.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/loop.c,v retrieving revision 1.5 diff -u -r1.5 loop.c --- Src/loop.c 2001/06/25 16:07:52 1.5 +++ Src/loop.c 2001/10/15 11:23:26 @@ -543,7 +543,7 @@ if (isset(XTRACE)) { char *pat2, *opat; - opat = pat = ecgetstr(state, EC_DUP, NULL); + pat = dupstring(opat = ecrawstr(state->prog, state->pc, NULL)); singsub(&pat); save = (!(state->prog->flags & EF_HEAP) && !strcmp(pat, opat) && *spprog != dummy_patprog2); @@ -565,7 +565,7 @@ char *opat; int htok = 0; - opat = pat = dupstring(ecrawstr(state->prog, + pat = dupstring(opat = ecrawstr(state->prog, state->pc - 2, &htok)); if (htok) singsub(&pat); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de