GNU bug report logs - #18266
grep -P and invalid exits with error

Previous Next

Package: grep;

Reported by: Santiago <santiago <at> debian.org>

Date: Thu, 14 Aug 2014 15:43:02 UTC

Severity: wishlist

Merged with 18455

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Norihiro Tanaka <noritnk <at> kcn.ne.jp>
Cc: 758105 <at> bugs.debian.org, Santiago <santiago <at> debian.org>,
 Vincent Lefevre <vincent <at> vinc17.net>, 18266 <at> debbugs.gnu.org
Subject: Re: bug#18266: grep -P and invalid exits with error
Date: Tue, 09 Sep 2014 17:00:51 -0700
Norihiro Tanaka wrote:
> I see that new version has no response for following test which was used
> previously.
>
>      printf '\x80ab\n' | env LC_ALL=en_US.utf8 src/grep -P '.?b'
>

Thanks for reporting that.  The test case works for me (Fedora 20 
x86-64, GCC 4.9.1):

$ printf '\x80ab\n' | env LC_ALL=en_US.utf8 src/grep -P '.?b' | od -c
0000000 200   a   b  \n
0000004

Fedora 20 is using pcre version 8.33-6.fc20; perhaps there's a PCRE 
version dependency here?  Can you use GDB to put a breakpoint on 
pcre_exec and see what values it's returning, and what it's storing into 
sub[0] and sub[1]?  Here's what I see (I compiled grep with '-g3 -O0'):

$ printf '\x80ab\n' >in
$ gdb src/grep
...
(gdb) b pcre_exec
...
(gdb) r -P '.?b' in
...
(gdb) fin
...
(gdb) n
...
(gdb) p e
$1 = -10
(gdb) c
...
(gdb) fin
...
(gdb) n
...
(gdb) p e
$2 = -1
(gdb) c
...
(gdb) fin
...
(gdb) n
...
(gdb) p e
$3 = 1
(gdb) p sub[0]
$4 = 0
(gdb) p sub[1]
$5 = 2
(gdb) p p
$6 = 0x62f001 "ab\n"
(gdb) p buf
$7 = 0x62f000 "\200ab\n"


That is, the first call to pcre_exec reports the encoding error, the 
second one (on the empty string) reports no match, and the third one (on 
"ab") finds the match.




This bug report was last modified 10 years and 249 days ago.

Previous Next


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