public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
* [Bug regex/29560] New: Wrong result with backreferences (test for non-prime numbers)
@ 2022-09-08 11:43 vincent-srcware at vinc17 dot net
  0 siblings, 0 replies; only message in thread
From: vincent-srcware at vinc17 dot net @ 2022-09-08 11:43 UTC (permalink / raw)
  To: glibc-bugs-regex

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-08 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 11:43 [Bug regex/29560] New: Wrong result with backreferences (test for non-prime numbers) vincent-srcware at vinc17 dot net

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).