public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
From: "vincent-srcware at vinc17 dot net" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs-regex@sourceware.org
Subject: [Bug regex/29560] New: Wrong result with backreferences (test for non-prime numbers)
Date: Thu, 08 Sep 2022 11:43:53 +0000	[thread overview]
Message-ID: <bug-29560-132@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=29560

            Bug ID: 29560
           Summary: Wrong result with backreferences (test for non-prime
                    numbers)
           Product: glibc
           Version: 2.31
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: regex
          Assignee: unassigned at sourceware dot org
          Reporter: vincent-srcware at vinc17 dot net
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Created attachment 14327
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14327&action=edit
Testcase written in C

zira:~> echo "1111111111111" | grep --color=always -E '^(11+)\1+$|^1?$'
1111111111111

with no colors, i.e. the matched portion is empty. This is incorrect: there
shouldn't be any match, as there are 13 digits 1 and 13 is a prime number.

This bug was initially reported in 2017 here:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884075
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29613

It was also added in Bug 11053 comment 6, but Bug 11053 was actually a
different bug.

If the "|^1?$" part is replaced by "|^$" (matching an empty string), the issue
still occurs, but if I remove it or replace it by a regexp that cannot match an
empty string, the issue no longer occurs.

I've attached a testcase written in C (almost the same as the one from Bug
11053 comment 6), using regcomp and regexec.

This bug is still there in glibc 2.35 (Ubuntu 22.04.1 LTS / riscv64).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

                 reply	other threads:[~2022-09-08 11:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29560-132@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs-regex@sourceware.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).