From: "Dmitry V. Levin" <ldv@altlinux.org>
To: Egor Ignatov <egori@altlinux.org>
Cc: Paul Eggert <eggert@cs.ucla.edu>, bug-gnulib@gnu.org
Subject: Re: [PATCH] regex: fix match with possessive quantifier
Date: Wed, 16 Jun 2021 13:18:05 +0300 [thread overview]
Message-ID: <20210616101805.GB8379@altlinux.org> (raw)
In-Reply-To: <20210607011027.GA18724@altlinux.org>
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 <egori@altlinux.org>
> > > ---
> > > 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
next prev parent reply other threads:[~2021-06-16 10:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 9:08 [PATCH] regex: fix match with possessive quantifier Egor Ignatov
2021-06-06 21:45 ` Dmitry V. Levin
2021-06-07 1:10 ` Dmitry V. Levin
2021-06-16 9:46 ` [PATCH] regex: fix backreference matching Egor Ignatov
2021-06-16 10:13 ` Dmitry V. Levin
2021-06-29 8:51 ` Egor Ignatov
2021-07-05 12:12 ` Dmitry V. Levin
2021-07-09 12:36 ` [PATCH v2] " Egor Ignatov
2021-06-16 10:18 ` Dmitry V. Levin [this message]
2021-06-21 21:09 ` [PATCH] regex: fix match with possessive quantifier Paul Eggert
2021-06-22 15:35 ` Egor Ignatov
2021-06-22 15:35 ` [PATCH] regex: fix assertion in re_node_set_insert Egor Ignatov
2021-06-22 19:41 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210616101805.GB8379@altlinux.org \
--to=ldv@altlinux.org \
--cc=bug-gnulib@gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=egori@altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).