From nobody Wed Mar 12 00:21:16 2025 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZCBBW56yrz5rGHj for ; Wed, 12 Mar 2025 00:21:23 +0000 (UTC) (envelope-from jamie@catflap.org) Received: from donotpassgo.dyslexicfish.net (donotpassgo.dyslexicfish.net [IPv6:2001:19f0:7400:8808:12:4:0:1]) by mx1.freebsd.org (Postfix) with ESMTP id 4ZCBBV5x22z3YDj; Wed, 12 Mar 2025 00:21:22 +0000 (UTC) (envelope-from jamie@catflap.org) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=pass (policy=none) header.from=catflap.org; spf=pass (mx1.freebsd.org: domain of jamie@catflap.org designates 2001:19f0:7400:8808:12:4:0:1 as permitted sender) smtp.mailfrom=jamie@catflap.org X-Catflap-Envelope-From: Received: from donotpassgo.dyslexicfish.net (donotpassgo.dyslexicfish.net [209.250.224.51]) by donotpassgo.dyslexicfish.net (8.14.5/8.14.5) with ESMTP id 52C0LG9C088610; Wed, 12 Mar 2025 00:21:16 GMT (envelope-from jamie@donotpassgo.dyslexicfish.net) Received: (from jamie@localhost) by donotpassgo.dyslexicfish.net (8.14.5/8.14.5/Submit) id 52C0LG7D088609; Wed, 12 Mar 2025 00:21:16 GMT (envelope-from jamie) From: Jamie Landeg-Jones Message-Id: <202503120021.52C0LG7D088609@donotpassgo.dyslexicfish.net> Date: Wed, 12 Mar 2025 00:21:16 +0000 Organization: Dyslexic Fish To: kevans@FreeBSD.org, jamie@catflap.org, freebsd-current@FreeBSD.org Subject: Re: grep(1) bug - duplicate output lines References: <202309280240.38S2esgN015958@donotpassgo.dyslexicfish.net> <8d0658e9-8984-a241-ad1d-e5aa1328d7fa@FreeBSD.org> <202309291629.38TGTU56092229@donotpassgo.dyslexicfish.net> <202309291825.38TIPNN2096338@donotpassgo.dyslexicfish.net> <85039cfe-3c59-173d-f2f2-f0ca8e0fa1c8@FreeBSD.org> <883774ff-c630-72bf-ebc3-cc53e4d40d03@FreeBSD.org> In-Reply-To: <883774ff-c630-72bf-ebc3-cc53e4d40d03@FreeBSD.org> User-Agent: Heirloom mailx 12.4 7/29/08 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.7 (donotpassgo.dyslexicfish.net [209.250.224.51]); Wed, 12 Mar 2025 00:21:16 +0000 (GMT) X-Spamd-Result: default: False [0.16 / 15.00]; NEURAL_HAM_SHORT(-0.96)[-0.960]; NEURAL_SPAM_LONG(0.92)[0.922]; NEURAL_SPAM_MEDIUM(0.90)[0.901]; DMARC_POLICY_ALLOW(-0.50)[catflap.org,none]; R_SPF_ALLOW(-0.20)[+mx:dyslexicfish.net]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FREEFALL_USER(0.00)[jamie]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; HAS_ORG_HEADER(0.00)[]; ASN(0.00)[asn:20473, ipnet:2001:19f0:7400::/38, country:US]; ARC_NA(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MLMMJ_DEST(0.00)[freebsd-current@FreeBSD.org]; R_DKIM_NA(0.00)[] X-Rspamd-Queue-Id: 4ZCBBV5x22z3YDj X-Spamd-Bar: / Kyle Evans wrote: > On 9/29/23 15:37, Kyle Evans wrote: > > On 9/29/23 13:25, Jamie Landeg-Jones wrote: > >> Jamie Landeg-Jones wrote: > >> > >>> Brilliant! Thanks for the quick response and fix. It works fine for me - > >>> I've not managed to break it again :-) > >> > >> Famous last words.... > >> > >> "grep -v" now produces duplicate lines! e.g. : > >> > > > > Alright, fine, be that way. :-) Try this on top of the existing patch: > > > > https://people.freebsd.org/~kevans/grep-color.diff > > > > This should be spelled: > > https://people.freebsd.org/~kevans/grep-color-addition.diff > > Sorry Hi Kyle. This is an old thread from 2023. ( https://lists.freebsd.org/archives/freebsd-current/2023-September/004762.html ) I've been running with these two patches since you posted them. I notice that they haven't been commited, and the bug reported in the thread still exists in current, so I'm replying to the original thread, both in the hope that this specific problem can be fixed, and then your overall fixes be submitted to the tree. Everything else has worked fine all this time, but today I noticed a bug that can be triggered like this: | % echo boo | /usr/bin/grep '' | Assertion failed: (pc->matchidx > 0), function procmatch_match, file /usr/src/usr.bin/grep/util.c, line 223. | Abort (core dumped) This is caused by the snippet: | /* Print the matching line, but only if not quiet/binary */ | if (mc->printmatch) { | size_t last_out; | | if (vflag) | assert(pc->matchidx == 0); | else | assert(pc->matchidx > 0); In this case, pc-matchidx is validly 0. However, simply Removing the assert from the src causes the duplicate line issue again. Why grep for '' ? Long story, but it seems to be allowed. Even if it isn't allowed, it shouldn't be dumping core :-) Anything further I can do to assist, please let me know. Cheers, Jamie