From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id EAA01709 for ; Tue, 30 Jul 1996 04:18:58 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id OAA21676; Mon, 29 Jul 1996 14:09:23 -0400 (EDT) Resent-Date: Mon, 29 Jul 1996 14:09:23 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199607291803.UAA05285@bolyai.cs.elte.hu> Subject: Re: Lethal option-related bug To: pws@ifh.de (Peter Stephenson) Date: Mon, 29 Jul 1996 20:03:45 +0200 (MET DST) Cc: zsh-workers@math.gatech.edu In-Reply-To: <199607291559.RAA10028@hydra.ifh.de> from Peter Stephenson at "Jul 29, 96 05:59:28 pm" Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL16 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"skCZn1.0.ZI5.IvF_n"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1828 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > I just submitted a batch job for the first time with an unpatched > 3.0-pre4 and it dumped core straight away. (I think the shell is > still yelling out `Don't release me! Don't release me!'.) OK, I'll make a 3.0-pre5 and will release 3.0 later in August. > It turns out to be easy to reproduce: > > ./zsh -s > zsh: 7863 segmentation fault (core dumped) ./zsh -s [...] > and the problem is that ifs is null in inittyptab; possibly not too > surprising, since it gets initialised in setupvals(), which is called > a few lines after parseargs() in main(). It looks like SHINSTDIN > wants inittytab set up before the shell's set up enough for it. > > I could probably hack round this, but I'm not confident of producing > the right fix, so I'll leave it. OK, below is a simple and clean fix. POSIX says that if IFS is unset it should be treated as if it were set to space-tab-newline. Zsh does this but it adds an extra null here. Zoltan *** Src/zsh.h 1996/07/28 22:29:59 2.36 --- Src/zsh.h 1996/07/29 08:59:08 *************** *** 57,62 **** --- 57,67 ---- #define Meta ((char) 0x83) + /* Note that the fourth character in DEFAULT_IFS is Meta * + * followed by a space which denotes the null character. */ + + #define DEFAULT_IFS " \t\n\203 " + /* Character tokens */ #define Pound ((char) 0x84) #define String ((char) 0x85) *** Src/utils.c 1996/07/21 15:00:57 2.46 --- Src/utils.c 1996/07/29 17:54:59 *************** *** 2507,2513 **** typtab[STOUC(Meta)] |= IMETA; for (t0 = (int)STOUC(Pound); t0 <= (int)STOUC(Nularg); t0++) typtab[t0] |= ITOK | IMETA; ! for (s = ifs; *s; s++) { if (inblank(*s)) if (s[1] == *s) s++; --- 2507,2513 ---- typtab[STOUC(Meta)] |= IMETA; for (t0 = (int)STOUC(Pound); t0 <= (int)STOUC(Nularg); t0++) typtab[t0] |= ITOK | IMETA; ! for (s = ifs ? ifs : DEFAULT_IFS; *s; s++) { if (inblank(*s)) if (s[1] == *s) s++; *** Src/params.c 1996/07/25 18:22:08 2.30 --- Src/params.c 1996/07/29 17:55:53 *************** *** 1574,1583 **** ifssetfn(Param pm, char *x) { zsfree(ifs); ! if (x) ! ifs = x; ! else ! ifs = ztrdup(" \t\n "), ifs[3] = Meta; inittyptab(); } --- 1574,1580 ---- ifssetfn(Param pm, char *x) { zsfree(ifs); ! ifs = x; inittyptab(); } *** Src/init.c 1996/07/27 20:24:36 2.35 --- Src/init.c 1996/07/29 17:57:54 *************** *** 520,527 **** if (!(ttystrname = ztrdup(ttyname(SHTTY)))) ttystrname = ztrdup(""); ! ifs = ztrdup(" \t\n "); ! ifs[3] = Meta; wordchars = ztrdup(DEFAULT_WORDCHARS); postedit = ztrdup(""); underscore = ztrdup(""); --- 520,526 ---- if (!(ttystrname = ztrdup(ttyname(SHTTY)))) ttystrname = ztrdup(""); ! ifs = ztrdup(DEFAULT_IFS); wordchars = ztrdup(DEFAULT_WORDCHARS); postedit = ztrdup(""); underscore = ztrdup("");