GNU bug report logs - #15758
grep 2.15 calls abort() on larger searches with -P

Previous Next

Package: grep;

Reported by: Dave Reisner <dreisner <at> archlinux.org>

Date: Wed, 30 Oct 2013 17:40:05 UTC

Severity: normal

Merged with 15759

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dave Reisner <dreisner <at> archlinux.org>
To: bug-grep <at> gnu.org
Subject: grep 2.15 calls abort() on larger searches with -P
Date: Wed, 30 Oct 2013 12:42:35 -0400
Hi,

A user reported a regression with grep 2.15 which is reasonably easy to
reproduce with an invocation such as: ``grep -Pr foo''. The root cause
is that pcre_exec returns an unhandled error (PCRE_ERROR_BADUTF8)
causing grep to call abort().

I bisected the breakage to commit 67436786c110bbb565 (and verified that
it still exists at git HEAD) which essentially introduces utf-8
validation for data. On a large enough file hierarchy, I suppose it's
inevitable that invalid UTF-8 data is encountered. I was able to fix
this with the inline diff which follows:

  diff --git a/src/pcresearch.c b/src/pcresearch.c
  index ad5999d..ce55ab3 100644
  --- a/src/pcresearch.c
  +++ b/src/pcresearch.c
  @@ -176,6 +176,9 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
         switch (e)
           {
           case PCRE_ERROR_NOMATCH:
  +#ifdef HAVE_LANGINFO_CODESET
  +        case PCRE_ERROR_BADUTF8:
  +#endif
             return -1;

           case PCRE_ERROR_NOMEMORY:

I don't know if this is considered to be a correct fix, but I offer it
as a starting point for a discussion.

Cheers,
Dave

P.S. Please CC me on replies as I am not subscribed to the list.




This bug report was last modified 11 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.