Subject: bug#18806: grep -rP getline crashes prematurely (without displaying all results) on invalid UTF-8 input with LC_ALL=en_US.UTF-8

From: Jim Meyering <[email-masked]>
Date: Sat, 25 Oct 2014 11:06:51 -0700

On Fri, Oct 24, 2014 at 1:38 PM, Paul Eggert <[email-masked]> wrote:
> Thanks for looking into this.  I added that test case, but took a
> more-conservative approach to fixing the bug, by disabling the optimization
> that's causing this problem; please see attached patches.  The optimization
> was a hack anyway, and these bugs suggest that it's not a hack worth
> keeping.

Hi Paul,
At first I thought "ok, either way."  But then I found that after your change,
our pcre-invalid-utf8-input hangs. That happens because the following
infloops (stuck in pcre_exec) on a CentOS6 system:

  printf 'j\202j\nj\nk\202\n' > in; LC_ALL=en_US.utf8 src/grep -P 'k$' in

That binary was linked with the libpcre from this package:

  pcre-7.8-4.el6.x86_64