From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 488321F5AE for ; Wed, 16 Jun 2021 10:18:47 +0000 (UTC) Received: from localhost ([::1]:44588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltSdC-0006kB-9p for normalperson@yhbt.net; Wed, 16 Jun 2021 06:18:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltSca-0006C7-R2 for bug-gnulib@gnu.org; Wed, 16 Jun 2021 06:18:08 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:45872) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltScZ-0002AK-1Q for bug-gnulib@gnu.org; Wed, 16 Jun 2021 06:18:08 -0400 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 8025672C8B0; Wed, 16 Jun 2021 13:18:05 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 57F267CC8B5; Wed, 16 Jun 2021 13:18:05 +0300 (MSK) Date: Wed, 16 Jun 2021 13:18:05 +0300 From: "Dmitry V. Levin" To: Egor Ignatov Subject: Re: [PATCH] regex: fix match with possessive quantifier Message-ID: <20210616101805.GB8379@altlinux.org> References: <20210526090819.7482-1-egori@altlinux.org> <20210606214502.GA16155@altlinux.org> <20210607011027.GA18724@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210607011027.GA18724@altlinux.org> Received-SPF: pass client-ip=194.107.17.57; envelope-from=ldv@altlinux.org; helo=vmicros1.altlinux.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On Mon, Jun 07, 2021 at 04:10:27AM +0300, Dmitry V. Levin wrote: > On Mon, Jun 07, 2021 at 12:45:02AM +0300, Dmitry V. Levin wrote: > > On Wed, May 26, 2021 at 12:08:19PM +0300, Egor Ignatov wrote: > > > Fix behaviour introduced in 70b673e, where regexps with > > > possessive quantifier("*+") didn't match. > > > * lib/regexec.c > > > (set_regs): Pop if CUR_NODE has already been checked only when > > > we have a fail stack. > > > > > > Signed-off-by: Egor Ignatov > > > --- > > > Hi Paul, > > > > > > Do you have any test cases for bug 11053(glibc) for gnulib? > > > This patch fixes the issue with "*+", but I'm not sure it > > > doesn't break your fix for 11053. > > > > Thanks, the fix looks plausible, it doesn't break any tests > > (including those introduced along with commit 70b673eb7), > > Apparently, there are more issues with commit 70b673eb7, for example: > > $ echo ab | sed -E 's/^(a*)*(.)\1/\1/' > Segmentation fault > > $ echo ab | strace -enone -- sed --debug -E 's/^(a*)*(.)\1/\1/' > SED PROGRAM: > s/^(a*)*(.)\\1/\1/ > INPUT: 'STDIN' line 1 > PATTERN: ab > COMMAND: s/^(a*)*(.)\\1/\1/ > MATCHED REGEX REGISTERS > regex[0] = 0-2 'ab' > regex[1] = 0--1 'ab!!ab > ' > --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x20} --- > +++ killed by SIGSEGV +++ > Segmentation fault And here is a tests/test-regex.c entry for this bug: diff --git a/tests/test-regex.c b/tests/test-regex.c index 7ea73cfb6..fdb1a1f1d 100644 --- a/tests/test-regex.c +++ b/tests/test-regex.c @@ -120,6 +120,8 @@ static struct { "^a*+(.)", "ab", REG_EXTENDED, 2, { { 0, 2 }, { 1, 2 } } }, /* Test for ** match. */ { "^(a*)*(.)", "ab", REG_EXTENDED, 3, { { 0, 2 }, { 0, 1 }, { 1, 2 } } }, + /* Test for ** match with backreferences. */ + { "^(a*)*\\1", "a", REG_EXTENDED, 2, { { 0, 0 }, { 0, 0 } } }, }; static void -- ldv