From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=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 98a4c10a for ; Fri, 24 May 2019 22:35:38 +0000 (UTC) Received: (qmail 3522 invoked by alias); 24 May 2019 22:35:20 -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: 44361 Received: (qmail 1400 invoked by uid 1010); 24 May 2019 22:35:20 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-8.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25454. spamassassin: 3.4.2. Clear:RC:0(80.0.253.72):SA:0(-2.0/5.0):. Processed in 2.496151 secs); 24 May 2019 22:35:20 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.72 as permitted sender) X-Originating-IP: [86.16.88.158] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=FYUZOq26 c=1 sm=1 tr=0 a=MiHCjVqLJ44lE3bxSlffFQ==:117 a=MiHCjVqLJ44lE3bxSlffFQ==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=-BYPCcN5L1INd1wpmAgA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1558737280; bh=gVKmp3zqA8E6j3u2eI0CC2yl0Gp8qPentW1N+3DPm1I=; h=Subject:From:To:Date:In-Reply-To:References; b=3puESP6C3tZPCYigB87LPSxAaQhnwStSi1Iwtea9RspVNypVSlpfUi5ARumxIojwI PVCuh3Ytzj9zLNdNgyuJXbNXbY9EEUUyOI7DNyMEE+ucUIKt+cHD4BGeuAY1UsVzSr amPbe+6YVCe4BlYzfPzRW2z158bOwGFUMM0aNimkMndeJpMFoQbmE1+/TJSMr0Sbeq B9M+ZSS4u1OjUjlW4XHoBHkCBw1s7xi2xlEPJlXhBBZ5pevroKeK+04Bf5kUcsWLU6 pSAe/3jb8CWeGSwisDN6IadA04ZtkhbxJH2V5tZ7p0h1zkxMIeSEmTH4/q7Jm+j8kK 7iuRVVVcm2upg== Message-ID: <6603cab122085bf3573cf721e6c676308015ce73.camel@ntlworld.com> Subject: Re: segfault via completion menu From: Peter Stephenson To: zsh-workers@zsh.org Date: Fri, 24 May 2019 23:34:39 +0100 In-Reply-To: <1558629258.12004.5.camel@samsung.com> References: <92606-1558385755.382793@sll5.5oha.0as1> <90e15b90-14bb-4ef0-9aef-cc15c0fa0935@www.fastmail.com> <1558514961.5043.7.camel@samsung.com> <1558629258.12004.5.camel@samsung.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfK56fPcGBK/51JRsef7cCP9ovqM+Wcz9oLLGUxkVb4xesEdhH2wmCPYBVy2Y5KanMy1/biNdPhpUDCUdn5Iwag1FdFhXLpRoQeg611DcmKpzLFGPPBRz bqLmeqZinPmRMhkHJebhdAbUaSH68QgADps9tGq7A7ZikTDCyzq369On On Thu, 2019-05-23 at 17:34 +0100, Peter Stephenson wrote: > On Wed, 2019-05-22 at 09:49 +0100, Peter Stephenson wrote: > > On Tue, 2019-05-21 at 15:19 -0700, Bart Schaefer wrote: > > It'll be something in the prog passed into pattry() from evalcond() and > > I'm guesing in this case the pprog in that function came from > > stat->prog->pats[npat] so was fished out of the existing programme > > rather than compiled locally. > > If so, something in the following assumptions is being violated, but I > can't see what from looking at the code. Alternatively, there could be some internal state in the pattern matching left over in the case of an error return --- there are variables that are intended to be used in recursive matching but currently aren't explicity initialised at the start of matching. It's not clear how that could happen, but it would be safest anyway to sanitise always on entry. pws diff --git a/Src/pattern.c b/Src/pattern.c index 737f5cdcb..3d30b013c 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -2030,6 +2030,16 @@ int errsfound; /* Total error count so far */ /**/ int forceerrs; /* Forced maximum error count */ +/* + * exactpos is used to remember how far down an exact string we have + * matched, if we are doing approximation and can therefore redo from + * the same point; we never need to otherwise. + * + * exactend is a pointer to the end of the string, which isn't + * null-terminated. + */ +static char *exactpos, *exactend; + /**/ void pattrystart(void) @@ -2463,6 +2473,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, patinput = patinstart; + exactpos = exactend = NULL; + /* The only external call to patmatch --- all others are recursive */ if (patmatch((Upat)progstr)) { /* * we were lazy and didn't save the globflags if an exclusion @@ -2652,16 +2664,6 @@ patmatchlen(void) #define CHARMATCH_EXPR(expr, chpa) \ (charmatch_cache = (expr), CHARMATCH(charmatch_cache, chpa)) -/* - * exactpos is used to remember how far down an exact string we have - * matched, if we are doing approximation and can therefore redo from - * the same point; we never need to otherwise. - * - * exactend is a pointer to the end of the string, which isn't - * null-terminated. - */ -static char *exactpos, *exactend; - /* * Main matching routine. *