GNU bug report logs - #19420
intermittent segfault using grep -P

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: grep; Reported by: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>; dated Sat, 20 Dec 2014 19:14:01 UTC; Maintainer for grep is bug-grep@HIDDEN.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 25 Dec 2014 08:53:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 25 03:53:08 2014
Received: from localhost ([127.0.0.1]:56900 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y44AO-0005ho-1K
	for submit <at> debbugs.gnu.org; Thu, 25 Dec 2014 03:53:08 -0500
Received: from lb2-smtp-cloud3.xs4all.net ([194.109.24.26]:47394)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y44AL-0005he-49
 for 19420 <at> debbugs.gnu.org; Thu, 25 Dec 2014 03:53:06 -0500
Received: from [192.168.0.130] ([82.95.251.247])
 by smtp-cloud3.xs4all.net with ESMTP
 id Xkt11p0095M1KXW01kt2k0; Thu, 25 Dec 2014 09:53:03 +0100
Message-ID: <549BD06D.6090308@HIDDEN>
Date: Thu, 25 Dec 2014 09:53:01 +0100
From: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: Paul Eggert <eggert@HIDDEN>, Norihiro Tanaka <noritnk@HIDDEN>
Subject: Re: bug#19420: intermittent segfault using grep -P
References: <5495E2C7.1060508@HIDDEN>
 <5496A1ED.6040207@HIDDEN>
 <20141223005501.1F34.27F6AC2D@HIDDEN>
 <54988DF1.3040906@HIDDEN> <5498CDEF.70100@HIDDEN>
In-Reply-To: <5498CDEF.70100@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 19420
Cc: 19420 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

FYI: I filed a bug with the pcre prject: 
http://bugs.exim.org/show_bug.cgi?id=1562

On 2014-12-23 03:05, Paul Eggert wrote:
> J.P. Hendrix wrote:
>> Are you saying a bug should be registered with pcre.org?
>
> That's what I'd suggest, yes.  I also can reproduce the bug with Mr. 
> Tanaka's recipe on CentOS 6.5 x86-64.  Wow, that's pretty deep 
> recursion that 'match' is doing....
>
>





Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 23 Dec 2014 02:05:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 22 21:05:48 2014
Received: from localhost ([127.0.0.1]:55397 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y3Er6-0006Rb-Ju
	for submit <at> debbugs.gnu.org; Mon, 22 Dec 2014 21:05:48 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:45994)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eggert@HIDDEN>) id 1Y3Er3-0006RQ-Ka
 for 19420 <at> debbugs.gnu.org; Mon, 22 Dec 2014 21:05:46 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
 by smtp.cs.ucla.edu (Postfix) with ESMTP id E356DA60042;
 Mon, 22 Dec 2014 18:05:44 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
 by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id FQUoZy2mvr6G; Mon, 22 Dec 2014 18:05:36 -0800 (PST)
Received: from [192.168.1.9] (pool-71-177-17-123.lsanca.dsl-w.verizon.net
 [71.177.17.123])
 by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 2CEA539E8015;
 Mon, 22 Dec 2014 18:05:36 -0800 (PST)
Message-ID: <5498CDEF.70100@HIDDEN>
Date: Mon, 22 Dec 2014 18:05:35 -0800
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.3.0
MIME-Version: 1.0
To: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>, 
 Norihiro Tanaka <noritnk@HIDDEN>
Subject: Re: bug#19420: intermittent segfault using grep -P
References: <5495E2C7.1060508@HIDDEN>
 <5496A1ED.6040207@HIDDEN>
 <20141223005501.1F34.27F6AC2D@HIDDEN>
 <54988DF1.3040906@HIDDEN>
In-Reply-To: <54988DF1.3040906@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 19420
Cc: 19420 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

J.P. Hendrix wrote:
> Are you saying a bug should be registered with pcre.org?

That's what I'd suggest, yes.  I also can reproduce the bug with Mr. Tanaka's 
recipe on CentOS 6.5 x86-64.  Wow, that's pretty deep recursion that 'match' is 
doing....





Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 22 Dec 2014 21:32:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 22 16:32:40 2014
Received: from localhost ([127.0.0.1]:55312 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y3Aal-0006RS-UN
	for submit <at> debbugs.gnu.org; Mon, 22 Dec 2014 16:32:40 -0500
Received: from lb2-smtp-cloud6.xs4all.net ([194.109.24.28]:55078)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y3Aaj-0006RI-DH
 for 19420 <at> debbugs.gnu.org; Mon, 22 Dec 2014 16:32:38 -0500
Received: from [192.168.0.130] ([82.95.251.247])
 by smtp-cloud6.xs4all.net with ESMTP
 id WlYZ1p00C5M1KXW01lYakJ; Mon, 22 Dec 2014 22:32:36 +0100
Message-ID: <54988DF1.3040906@HIDDEN>
Date: Mon, 22 Dec 2014 22:32:33 +0100
From: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: Norihiro Tanaka <noritnk@HIDDEN>
Subject: Re: bug#19420: intermittent segfault using grep -P
References: <5495E2C7.1060508@HIDDEN>
 <5496A1ED.6040207@HIDDEN>
 <20141223005501.1F34.27F6AC2D@HIDDEN>
In-Reply-To: <20141223005501.1F34.27F6AC2D@HIDDEN>
Content-Type: multipart/alternative;
 boundary="------------070000010309010809020607"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 19420
Cc: 19420 <at> debbugs.gnu.org, Paul Eggert <eggert@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

This is a multi-part message in MIME format.
--------------070000010309010809020607
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit

I'm not a developer, so please bear with me here. You kinda lost me with 
below analysis, but I think I managed to reproduce your findings with a 
bit of Google-magic. Are you saying a bug should be registered with 
pcre.org?

I am reproducing your findings as follows:

 sudo apt-get install libpcre3-dbg libpcre3-dev   # these were already 
installed.

 tar xzf pcre-8.36.tar.gz
 cd pcre-8.36
 CFLAGS=-g ./configure --enable-utf --enable-unicode-properties 
--prefix=/tmp/segfaultGrep
 make
 make install

 gcc reproduce.c -L/tmp/segfaultGrep/lib -lpcre
 LD_LIBRARY_PATH=/tmp/segfaultGrep/lib ./a.out; echo $?
Segmentation fault (core dumped)
139

Please check my notes and advice how to go forward.

Kind regards,

JP



On 2014-12-22 16:55, Norihiro Tanaka wrote:
> It could reproduce as following in Fedora21, RHEL 6.5.
>
> $ cd pcre-8.36
> $ CFLAGS=-g ./configure --enable-utf --enable-unicode-properties
> $ make
> # make install
>
> grep-2.21
> $ ./configure
> $ make
> # make install
>
> By the way, if we enabled to optimize or recompile pcre with --enable-jit
> option, it did not reproduced.
>
> However, I see that it is an issue in PRE side.  It reproduces with
> following test case without grep frontend.
>
> ==
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <pcre.h>
>
> enum { LEN = 15000 };
> enum { NSUB = 300 };
>
> int
> main ()
> {
>    char *text = malloc ((LEN + 1) * sizeof *text);
>    memset (text, '0', LEN);
>    text[LEN] = '\0';
>    char const *re = "0(?:(?!foo).)+";
>    char const *ep;
>    int eo;
>
>    pcre *cre = pcre_compile (re, 0, &ep, &eo, NULL);
>    if (!cre)
>      exit (EXIT_FAILURE);
>
>    int sub[NSUB];
>    pcre_exec (cre, NULL, text, strlen (text), 0, 0, sub, NSUB);
>
>    exit (EXIT_SUCCESS);
> }
> ==
>
>


--------------070000010309010809020607
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    I'm not a developer, so please bear with me here. You kinda lost me
    with below analysis, but I think I managed to reproduce your
    findings with a bit of Google-magic. Are you saying a bug should be
    registered with pcre.org?<br>
    <br>
    I am reproducing your findings as follows: <br>
    <br>
    <font face="Courier New, Courier, monospace"> sudo apt-get install
      libpcre3-dbg libpcre3-dev # these were already installed.<br>
    </font><br>
    <font face="Courier New, Courier, monospace"> tar xzf
      pcre-8.36.tar.gz<br>
       cd pcre-8.36<br>
       CFLAGS=-g ./configure --enable-utf --enable-unicode-properties
      --prefix=/tmp/segfaultGrep<br>
       make<br>
       make install</font><br>
    <br>
    <font face="Courier New, Courier, monospace"> gcc reproduce.c
      -L/tmp/segfaultGrep/lib -lpcre</font><br>
    <font face="Courier New, Courier, monospace">
      LD_LIBRARY_PATH=/tmp/segfaultGrep/lib ./a.out; echo $?</font><br>
    <font face="Courier New, Courier, monospace">Segmentation fault
      (core dumped)<br>
      139<br>
    </font><br>
    Please check my notes and advice how to go forward.<br>
    <br>
    Kind regards,<br>
    <br>
    JP<br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 2014-12-22 16:55, Norihiro Tanaka
      wrote:<br>
    </div>
    <blockquote cite="mid:20141223005501.1F34.27F6AC2D@HIDDEN"
      type="cite">
      <pre wrap="">It could reproduce as following in Fedora21, RHEL 6.5.

$ cd pcre-8.36
$ CFLAGS=-g ./configure --enable-utf --enable-unicode-properties
$ make
# make install

grep-2.21
$ ./configure
$ make
# make install

By the way, if we enabled to optimize or recompile pcre with --enable-jit
option, it did not reproduced.

However, I see that it is an issue in PRE side.  It reproduces with
following test case without grep frontend.

==
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;pcre.h&gt;

enum { LEN = 15000 };
enum { NSUB = 300 };

int
main ()
{
  char *text = malloc ((LEN + 1) * sizeof *text);
  memset (text, '0', LEN);
  text[LEN] = '\0';
  char const *re = "0(?:(?!foo).)+";
  char const *ep;
  int eo;

  pcre *cre = pcre_compile (re, 0, &amp;ep, &amp;eo, NULL);
  if (!cre)
    exit (EXIT_FAILURE);

  int sub[NSUB];
  pcre_exec (cre, NULL, text, strlen (text), 0, 0, sub, NSUB);

  exit (EXIT_SUCCESS);
}
==


</pre>
    </blockquote>
    <br>
  </body>
</html>

--------------070000010309010809020607--




Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 22 Dec 2014 15:55:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 22 10:55:09 2014
Received: from localhost ([127.0.0.1]:55067 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y35K9-0004t0-2y
	for submit <at> debbugs.gnu.org; Mon, 22 Dec 2014 10:55:09 -0500
Received: from mailgw04.kcn.ne.jp ([61.86.7.211]:57968)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <noritnk@HIDDEN>) id 1Y35K5-0004so-3B
 for 19420 <at> debbugs.gnu.org; Mon, 22 Dec 2014 10:55:06 -0500
Received: from imp01 (mailgw5.kcn.ne.jp [61.86.15.231])
 by mailgw04.kcn.ne.jp (Postfix) with ESMTP id 560636C1C32
 for <19420 <at> debbugs.gnu.org>; Tue, 23 Dec 2014 00:55:02 +0900 (JST)
Received: from mail08.kcn.ne.jp ([61.86.6.187]) by imp01 with bizsmtp
 id Wfv21p007426eXR01fv2Tb; Tue, 23 Dec 2014 00:55:02 +0900
X-OrgRCPT: 19420 <at> debbugs.gnu.org
Received: from [10.120.1.67] (i118-21-128-66.s30.a048.ap.plala.or.jp
 [118.21.128.66])
 by mail08.kcn.ne.jp (Postfix) with ESMTPA id 110F412B802E;
 Tue, 23 Dec 2014 00:55:02 +0900 (JST)
Date: Tue, 23 Dec 2014 00:55:02 +0900
From: Norihiro Tanaka <noritnk@HIDDEN>
To: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>
Subject: Re: bug#19420: intermittent segfault using grep -P
In-Reply-To: <5496A1ED.6040207@HIDDEN>
References: <5495E2C7.1060508@HIDDEN>
 <5496A1ED.6040207@HIDDEN>
Message-Id: <20141223005501.1F34.27F6AC2D@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
X-Mailer: Becky! ver. 2.65.07 [ja]
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 19420
Cc: 19420 <at> debbugs.gnu.org, Paul Eggert <eggert@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

It could reproduce as following in Fedora21, RHEL 6.5.

$ cd pcre-8.36
$ CFLAGS=-g ./configure --enable-utf --enable-unicode-properties
$ make
# make install

grep-2.21
$ ./configure
$ make
# make install

By the way, if we enabled to optimize or recompile pcre with --enable-jit
option, it did not reproduced.

However, I see that it is an issue in PRE side.  It reproduces with
following test case without grep frontend.

==
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pcre.h>

enum { LEN = 15000 };
enum { NSUB = 300 };

int
main ()
{
  char *text = malloc ((LEN + 1) * sizeof *text);
  memset (text, '0', LEN);
  text[LEN] = '\0';
  char const *re = "0(?:(?!foo).)+";
  char const *ep;
  int eo;

  pcre *cre = pcre_compile (re, 0, &ep, &eo, NULL);
  if (!cre)
    exit (EXIT_FAILURE);

  int sub[NSUB];
  pcre_exec (cre, NULL, text, strlen (text), 0, 0, sub, NSUB);

  exit (EXIT_SUCCESS);
}
==





Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 21 Dec 2014 10:33:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 21 05:33:26 2014
Received: from localhost ([127.0.0.1]:53435 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y2dpE-0007lt-Vz
	for submit <at> debbugs.gnu.org; Sun, 21 Dec 2014 05:33:26 -0500
Received: from lb2-smtp-cloud6.xs4all.net ([194.109.24.28]:50675)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2dpB-0007lk-SX
 for 19420 <at> debbugs.gnu.org; Sun, 21 Dec 2014 05:33:23 -0500
Received: from [192.168.0.130] ([82.95.251.247])
 by smtp-cloud6.xs4all.net with ESMTP
 id WAZH1p00C5M1KXW01AZKsw; Sun, 21 Dec 2014 11:33:20 +0100
Message-ID: <5496A1ED.6040207@HIDDEN>
Date: Sun, 21 Dec 2014 11:33:17 +0100
From: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: Paul Eggert <eggert@HIDDEN>, 19420 <at> debbugs.gnu.org, noritnk@HIDDEN
Subject: Re: bug#19420: intermittent segfault using grep -P
References: <5495478C.9090303@HIDDEN>
 <5495E2C7.1060508@HIDDEN>
In-Reply-To: <5495E2C7.1060508@HIDDEN>
Content-Type: multipart/alternative;
 boundary="------------050300030103000301060001"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 19420
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

This is a multi-part message in MIME format.
--------------050300030103000301060001
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

My feedback to your questions:

    In addition, please recompile grep with `-g' and if it is reproduced,
    get backtrace from a core file with gdb and send it to us.

       $ CFLAGS=-g ./configure OPTIONS
       $ make
       $ cat grepTxt | grep -P 'b(?:(?!tom).)+'
       $ gdb src/grep core.*

       (gdb) bt

Recompiling
*# **Core files are not dumped by default, enabling that.*
€ ulimit -c unlimited
€ ulimit -a
core file size          (blocks, -c) unlimited
...

*# Fresh compile*
€ tar xf grep-2.21.tar       # new fresh directory.
€ cd grep-2.21
€ CFLAGS=-g ./configure --prefix=/tmp/segfaultGrep/grep/
...
€ make
...
€ cat ../../grepTxt | ./src/grep -qP 'b(?:(?!tom).)+'
../bin/grep: warning: GREP_OPTIONS is deprecated; please use an alias or 
script
Segmentation fault (core dumped)

*# Only one core file is found, but not matching 'core.*'**
**# I have no experience with gdb, so I cannot really judge gdb output**
*€ find /tmp/segfaultGrep/ | grep -i core
/tmp/segfaultGrep/grep/grep-2.21/core
€ gdb src/grep core
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
...
This GDB was configured as "x86_64-linux-gnu".
...
Reading symbols from src/grep...done.
[New LWP 1357]
Core was generated by `./src/grep -qP b(?:(?!tom).)+'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fd8a278054a in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
(gdb) bt
#0  0x00007fd8a278054a in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#1  0x00007fd8a2780ecb in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#2  0x00007fd8a278dcfa in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#3  0x00007fd8a278dcfa in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#4  0x00007fd8a278dcfa in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
...
#16890 0x00007fd8a278dcfa in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#16891 0x00007fd8a278dcfa in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#16892 0x00007fd8a278dcfa in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#16893 0x00007fd8a2791221 in pcre_exec () from 
/lib/x86_64-linux-gnu/libpcre.so.3
#16894 0x000000000041621d in Pexecute (
     buf=0x13fc000 
"b3VuZDwvaDE+Iik7fQoKJGxhbmd1YWdlPSdlbmcnOwoKJGF1dGggPSAwOwoKJG5hbWU9Jyc7IAokcGFzcz0nJzsKCi8vcnVfUlUsIC8vcnVfUlUuY3AxMjUxLCAvL3J1X1JVLmlzbzg4NTk1LCAvL3J1X1JVLmtvaThyLCAvL3J1X1JVLnV0ZjgKQHNldGxvY2FsZShM"..., 
size=16893, match_size=0x7fffa0333150, start_ptr=0x0) at pcresearch.c:215
#16895 0x0000000000404b95 in grepbuf (
     beg=0x13fc000 
"b3VuZDwvaDE+Iik7fQoKJGxhbmd1YWdlPSdlbmcnOwoKJGF1dGggPSAwOwoKJG5hbWU9Jyc7IAokcGFzcz0nJzsKCi8vcnVfUlUsIC8vcnVfUlUuY3AxMjUxLCAvL3J1X1JVLmlzbzg4NTk1LCAvL3J1X1JVLmtvaThyLCAvL3J1X1JVLnV0ZjgKQHNldGxvY2FsZShM"..., 
lim=0x14001fd "\377") at grep.c:1232
#16896 0x0000000000404fcb in grep (fd=0, st=0x7fffa0333260) at grep.c:1350
#16897 0x0000000000405aad in grepdesc (desc=0, command_line=true) at 
grep.c:1639
#16898 0x0000000000405ca4 in grep_command_line_arg (arg=0x42440e "-") at 
grep.c:1686
#16899 0x000000000040774d in main (argc=4, argv=0x13fa080) at grep.c:2564

*# OK, I guess I know enough about gdb to understand we're missing 
symbols in the output ...*
€ sudo apt-get install libpcre3-dbg
...

*# Working around almost 10 megabyte **output text...*
€ echo bt > bt
€ gdb src/grep core --batch -x bt > /tmp/gdb.out
484     pcre_exec.c: No such file or directory.
*# http://wirespeed.xs4all.nl/media/segfaultGrep/*


I checked on a VM on my laptop, but I can't reproduce the issue there. 
It is 32 bit Ubuntu 14.04.1

I double checked the intermittent behavior on my PC, don't have a reason 
to believe it is hardware related because my system is otherwise stable. 
I found these messages in 'dmesg' after checking the command couple 
times, notice the 'libpcre'.

€ dmesg
[2119696.762373] grep[6488]: segfault at 7fff51de7fe8 ip 
00007f5db8a3454a sp 00007fff51de7fe0 error 6 in 
*libpcre*.so.3.13.1[7f5db8a21000+3d000]
[2119697.880722] grep[6569]: segfault at 7ffffcd28ff8 ip 
00007f00ae1ea53d sp 00007ffffcd28e50 error 6 in 
libpcre.so.3.13.1[7f00ae1d7000+3d000]
[2119698.811133] grep[6646]: segfault at 7fff6252fec8 ip 
00007f0c7545754a sp 00007fff6252fec0 error 6 in 
libpcre.so.3.13.1[7f0c75444000+3d000]
[2119699.674442] grep[6708]: segfault at 7fff5fdcdee8 ip 
00007fb27fa3b54a sp 00007fff5fdcdee0 error 6 in 
libpcre.so.3.13.1[7fb27fa28000+3d000]
[2119700.488632] grep[6770]: segfault at 7fff8fda7ff8 ip 
00007f7791bc5ec6 sp 00007fff8fda8000 error 6 in 
libpcre.so.3.13.1[7f7791bb2000+3d000]
[2119701.274100] grep[6822]: segfault at 7fff29bd8f18 ip 
00007fb0bd44d54a sp 00007fff29bd8f10 error 6 in 
libpcre.so.3.13.1[7fb0bd43a000+3d000]
[2119702.090632] grep[6890]: segfault at 7fffa33f8ee8 ip 
00007fd4b786954a sp 00007fffa33f8ee0 error 6 in 
libpcre.so.3.13.1[7fd4b7856000+3d000]
[2119702.875331] grep[6943]: segfault at 7fffb0b0efd8 ip 
00007fc2a9d7554a sp 00007fffb0b0efd0 error 6 in 
libpcre.so.3.13.1[7fc2a9d62000+3d000]
[2119715.819686] grep[7795]: segfault at 7fff20e78e68 ip 
00007fd5162c854a sp 00007fff20e78e60 error 6 in 
libpcre.so.3.13.1[7fd5162b5000+3d000]
[2119717.595114] grep[7913]: segfault at 7fff2bc21fd8 ip 
00007f30455ec54a sp 00007fff2bc21fd0 error 6 in 
libpcre.so.3.13.1[7f30455d9000+3d000]



I believe I mentioned libpcre3:amd64 1:8.*31*-2ubuntu2 before, but here 
it is for completeness.

€ locale
LANG=en_US.UTF-8
LANGUAGE=en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=




On 2014-12-20 21:57, Paul Eggert wrote:
> I can't reproduce the problem on Ubuntu 14.10 (x86-64) or Fedora 20 
> (x86-64), with either the bundled grep or with GNU grep 2.21.
>
> What locale are you running in?  What's the output of the 'locale' 
> command?
>
> It could be a bug in grep, or in libpcre, or somewhere else. Ubuntu 
> 14.10 is running libpcre3 1:8.35-3ubuntu1.  I vaguely recall that 
> they're doing something funky to prevent grep from depending on 
> libpcre while still supporting -P, but I don't recall the details.
>


--------------050300030103000301060001
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    My feedback to your questions:<br>
    <blockquote>
      <pre wrap="">In addition, please recompile grep with `-g' and if it is reproduced,
get backtrace from a core file with gdb and send it to us.

  $ CFLAGS=-g ./configure OPTIONS
  $ make
  $ cat grepTxt | grep -P 'b(?:(?!tom).)+'
  $ gdb src/grep core.*

  (gdb) bt</pre>
    </blockquote>
    <table width="100%" border="1" cellpadding="2" cellspacing="2">
      <tbody>
        <tr>
          <td valign="top"><font face="Courier New, Courier, monospace">Recompiling</font><br>
          </td>
        </tr>
        <tr>
          <td valign="top"><font face="Courier New, Courier, monospace"><b>#
              </b><b>Core files are not dumped by default, enabling
                that.</b><br>
              € ulimit -c unlimited<br>
              € ulimit -a<br>
              core file size          (blocks, -c) unlimited<br>
              ...<br>
              <br>
              <b># Fresh compile</b><br>
              € tar xf grep-2.21.tar       # new fresh directory.<br>
              € cd grep-2.21<br>
              € CFLAGS=-g ./configure --prefix=/tmp/segfaultGrep/grep/<br>
              ...<br>
              € make<br>
              ...<br>
              € cat ../../grepTxt | ./src/grep -qP 'b(?:(?!tom).)+'<br>
              ../bin/grep: warning: GREP_OPTIONS is deprecated; please
              use an alias or script<br>
              Segmentation fault (core dumped)</font><br>
            <br>
            <font face="Courier New, Courier, monospace"><b># Only one
                core file is found, but not matching 'core.*'</b><b><br>
              </b><b># I have no experience with gdb, so I cannot really
                judge gdb output</b><b><br>
              </b>€ find /tmp/segfaultGrep/ | grep -i core<br>
              /tmp/segfaultGrep/grep/grep-2.21/core<br>
              € gdb src/grep core<br>
              GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1<br>
              ...<br>
              This GDB was configured as "x86_64-linux-gnu".<br>
              ...<br>
              Reading symbols from src/grep...done.<br>
              [New LWP 1357]<br>
              Core was generated by `./src/grep -qP b(?:(?!tom).)+'.<br>
              Program terminated with signal SIGSEGV, Segmentation
              fault.<br>
              #0  0x00007fd8a278054a in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              (gdb) bt<br>
              #0  0x00007fd8a278054a in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #1  0x00007fd8a2780ecb in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #2  0x00007fd8a278dcfa in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #3  0x00007fd8a278dcfa in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #4  0x00007fd8a278dcfa in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3</font><br>
            <font face="Courier New, Courier, monospace">...<br>
              #16890 0x00007fd8a278dcfa in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #16891 0x00007fd8a278dcfa in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #16892 0x00007fd8a278dcfa in ?? () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #16893 0x00007fd8a2791221 in pcre_exec () from
              /lib/x86_64-linux-gnu/libpcre.so.3<br>
              #16894 0x000000000041621d in Pexecute (<br>
                  buf=0x13fc000
              "b3VuZDwvaDE+Iik7fQoKJGxhbmd1YWdlPSdlbmcnOwoKJGF1dGggPSAwOwoKJG5hbWU9Jyc7IAokcGFzcz0nJzsKCi8vcnVfUlUsIC8vcnVfUlUuY3AxMjUxLCAvL3J1X1JVLmlzbzg4NTk1LCAvL3J1X1JVLmtvaThyLCAvL3J1X1JVLnV0ZjgKQHNldGxvY2FsZShM"...,
              size=16893, match_size=0x7fffa0333150, start_ptr=0x0) at
              pcresearch.c:215<br>
              #16895 0x0000000000404b95 in grepbuf (<br>
                  beg=0x13fc000
              "b3VuZDwvaDE+Iik7fQoKJGxhbmd1YWdlPSdlbmcnOwoKJGF1dGggPSAwOwoKJG5hbWU9Jyc7IAokcGFzcz0nJzsKCi8vcnVfUlUsIC8vcnVfUlUuY3AxMjUxLCAvL3J1X1JVLmlzbzg4NTk1LCAvL3J1X1JVLmtvaThyLCAvL3J1X1JVLnV0ZjgKQHNldGxvY2FsZShM"...,
              lim=0x14001fd "\377") at grep.c:1232<br>
              #16896 0x0000000000404fcb in grep (fd=0,
              st=0x7fffa0333260) at grep.c:1350<br>
              #16897 0x0000000000405aad in grepdesc (desc=0,
              command_line=true) at grep.c:1639<br>
              #16898 0x0000000000405ca4 in grep_command_line_arg
              (arg=0x42440e "-") at grep.c:1686<br>
              #16899 0x000000000040774d in main (argc=4, argv=0x13fa080)
              at grep.c:2564</font><br>
            <br>
            <b><font face="Courier New, Courier, monospace"># OK, I
                guess I know enough about gdb to understand we're
                missing symbols in the output ...</font></b><br>
            <font face="Courier New, Courier, monospace">€ sudo apt-get
              install libpcre3-dbg<br>
              ...<br>
              <br>
              <b># Working around almost 10 megabyte </b><b>output
                text...</b><br>
              € echo bt &gt; bt<br>
              € gdb src/grep core --batch -x bt &gt; /tmp/gdb.out<br>
              484     pcre_exec.c: No such file or directory.<br>
              <b># <a class="moz-txt-link-freetext" href="http://wirespeed.xs4all.nl/media/segfaultGrep/">http://wirespeed.xs4all.nl/media/segfaultGrep/</a></b><br>
            </font></td>
        </tr>
      </tbody>
    </table>
    <br>
    I checked on a VM on my laptop, but I can't reproduce the issue
    there. It is 32 bit Ubuntu 14.04.1 <br>
    <br>
    I double checked the intermittent behavior on my PC, don't have a
    reason to believe it is hardware related because my system is
    otherwise stable. I found these messages in 'dmesg' after checking
    the command couple times, notice the 'libpcre'.<br>
    <br>
    <table width="100%" border="1" cellpadding="2" cellspacing="2">
      <tbody>
        <tr>
          <td valign="top"><font face="Courier New, Courier, monospace">€
              dmesg</font><br>
          </td>
        </tr>
        <tr>
          <td valign="top"><font face="Courier New, Courier, monospace">[2119696.762373]
              grep[6488]: segfault at 7fff51de7fe8 ip 00007f5db8a3454a
              sp 00007fff51de7fe0 error 6 in <b>libpcre</b>.so.3.13.1[7f5db8a21000+3d000]<br>
              [2119697.880722] grep[6569]: segfault at 7ffffcd28ff8 ip
              00007f00ae1ea53d sp 00007ffffcd28e50 error 6 in
              libpcre.so.3.13.1[7f00ae1d7000+3d000]<br>
              [2119698.811133] grep[6646]: segfault at 7fff6252fec8 ip
              00007f0c7545754a sp 00007fff6252fec0 error 6 in
              libpcre.so.3.13.1[7f0c75444000+3d000]<br>
              [2119699.674442] grep[6708]: segfault at 7fff5fdcdee8 ip
              00007fb27fa3b54a sp 00007fff5fdcdee0 error 6 in
              libpcre.so.3.13.1[7fb27fa28000+3d000]<br>
              [2119700.488632] grep[6770]: segfault at 7fff8fda7ff8 ip
              00007f7791bc5ec6 sp 00007fff8fda8000 error 6 in
              libpcre.so.3.13.1[7f7791bb2000+3d000]<br>
              [2119701.274100] grep[6822]: segfault at 7fff29bd8f18 ip
              00007fb0bd44d54a sp 00007fff29bd8f10 error 6 in
              libpcre.so.3.13.1[7fb0bd43a000+3d000]<br>
              [2119702.090632] grep[6890]: segfault at 7fffa33f8ee8 ip
              00007fd4b786954a sp 00007fffa33f8ee0 error 6 in
              libpcre.so.3.13.1[7fd4b7856000+3d000]<br>
              [2119702.875331] grep[6943]: segfault at 7fffb0b0efd8 ip
              00007fc2a9d7554a sp 00007fffb0b0efd0 error 6 in
              libpcre.so.3.13.1[7fc2a9d62000+3d000]<br>
              [2119715.819686] grep[7795]: segfault at 7fff20e78e68 ip
              00007fd5162c854a sp 00007fff20e78e60 error 6 in
              libpcre.so.3.13.1[7fd5162b5000+3d000]<br>
              [2119717.595114] grep[7913]: segfault at 7fff2bc21fd8 ip
              00007f30455ec54a sp 00007fff2bc21fd0 error 6 in
              libpcre.so.3.13.1[7f30455d9000+3d000]</font><br>
          </td>
        </tr>
      </tbody>
    </table>
    <br>
    <br>
    I believe I mentioned libpcre3:amd64 1:8.<b>31</b>-2ubuntu2 before,
    but here it is for completeness.<br>
    <br>
    <div class="moz-cite-prefix">
      <table width="100%" border="1" cellpadding="2" cellspacing="2">
        <tbody>
          <tr>
            <td valign="top"><font face="Courier New, Courier,
                monospace">€ locale</font><br>
            </td>
          </tr>
          <tr>
            <td valign="top"><font face="Courier New, Courier,
                monospace">LANG=en_US.UTF-8<br>
                LANGUAGE=en<br>
                LC_CTYPE="en_US.UTF-8"<br>
                LC_NUMERIC=en_US.UTF-8<br>
                LC_TIME=en_US.UTF-8<br>
                LC_COLLATE="en_US.UTF-8"<br>
                LC_MONETARY=en_US.UTF-8<br>
                LC_MESSAGES="en_US.UTF-8"<br>
                LC_PAPER=en_US.UTF-8<br>
                LC_NAME=en_US.UTF-8<br>
                LC_ADDRESS=en_US.UTF-8<br>
                LC_TELEPHONE=en_US.UTF-8<br>
                LC_MEASUREMENT=en_US.UTF-8<br>
                LC_IDENTIFICATION=en_US.UTF-8<br>
                LC_ALL=</font><br>
            </td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <br>
      On 2014-12-20 21:57, Paul Eggert wrote:<br>
    </div>
    <blockquote cite="mid:5495E2C7.1060508@HIDDEN" type="cite">I
      can't reproduce the problem on Ubuntu 14.10 (x86-64) or Fedora 20
      (x86-64), with either the bundled grep or with GNU grep 2.21.
      <br>
      <br>
      What locale are you running in?  What's the output of the 'locale'
      command?
      <br>
      <br>
      It could be a bug in grep, or in libpcre, or somewhere else. 
      Ubuntu 14.10 is running libpcre3 1:8.35-3ubuntu1.  I vaguely
      recall that they're doing something funky to prevent grep from
      depending on libpcre while still supporting -P, but I don't recall
      the details.
      <br>
      <br>
    </blockquote>
    <br>
  </body>
</html>

--------------050300030103000301060001--




Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 21 Dec 2014 00:56:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 19:56:42 2014
Received: from localhost ([127.0.0.1]:53342 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y2Up8-0001di-4B
	for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 19:56:42 -0500
Received: from mailgw01.kcn.ne.jp ([61.86.7.208]:51874)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <noritnk@HIDDEN>) id 1Y2Up5-0001dW-Db
 for 19420 <at> debbugs.gnu.org; Sat, 20 Dec 2014 19:56:40 -0500
Received: from imp01 (mailgw5.kcn.ne.jp [61.86.15.231])
 by mailgw01.kcn.ne.jp (Postfix) with ESMTP id 3AC0580328
 for <19420 <at> debbugs.gnu.org>; Sun, 21 Dec 2014 09:56:36 +0900 (JST)
Received: from mail02.kcn.ne.jp ([61.86.6.181]) by imp01 with bizsmtp
 id W0wc1p0043uLcVp010wc3H; Sun, 21 Dec 2014 09:56:36 +0900
X-OrgRCPT: 19420 <at> debbugs.gnu.org
Received: from [10.120.1.73] (i118-21-128-66.s30.a048.ap.plala.or.jp
 [118.21.128.66])
 by mail02.kcn.ne.jp (Postfix) with ESMTPA id E801FF10025;
 Sun, 21 Dec 2014 09:56:35 +0900 (JST)
Date: Sun, 21 Dec 2014 09:56:38 +0900
From: Norihiro Tanaka <noritnk@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#19420: intermittent segfault using grep -P
In-Reply-To: <5495E341.1000000@HIDDEN>
References: <5495E2C7.1060508@HIDDEN> <5495E341.1000000@HIDDEN>
Message-Id: <20141221095637.74B1.27F6AC2D@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
X-Mailer: Becky! ver. 2.65.07 [ja]
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 19420
Cc: 19420 <at> debbugs.gnu.org, "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

In addition, please recompile grep with `-g' and if it is reproduced,
get backtrace from a core file with gdb and send it to us.

  $ CFLAGS=-g ./configure OPTIONS
  $ make
  $ cat grepTxt | grep -P 'b(?:(?!tom).)+'
  $ gdb src/grep core.*

  (gdb) bt





Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 20 Dec 2014 20:59:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 15:59:58 2014
Received: from localhost ([127.0.0.1]:53319 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y2R82-0003SX-2X
	for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 15:59:58 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:52075)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eggert@HIDDEN>) id 1Y2R7z-0003SL-Hp
 for 19420 <at> debbugs.gnu.org; Sat, 20 Dec 2014 15:59:55 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
 by smtp.cs.ucla.edu (Postfix) with ESMTP id E6A3DA60033;
 Sat, 20 Dec 2014 12:59:54 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
 by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id VuTe433fD5xL; Sat, 20 Dec 2014 12:59:46 -0800 (PST)
Received: from [192.168.1.9] (pool-71-177-17-123.lsanca.dsl-w.verizon.net
 [71.177.17.123])
 by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 50F7CA60017;
 Sat, 20 Dec 2014 12:59:46 -0800 (PST)
Message-ID: <5495E341.1000000@HIDDEN>
Date: Sat, 20 Dec 2014 12:59:45 -0800
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.3.0
MIME-Version: 1.0
To: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>, 
 19420 <at> debbugs.gnu.org
Subject: Re: bug#19420: intermittent segfault using grep -P
References: <5495478C.9090303@HIDDEN>
 <5495E2C7.1060508@HIDDEN>
In-Reply-To: <5495E2C7.1060508@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 19420
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

One more thing.  It's odd that you get a segfault only 10 times out of 16.  So 
another possibility is that you have a hardware problem.  Can you reproduce the 
bug on some other machine?




Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at 19420 <at> debbugs.gnu.org:


Received: (at 19420) by debbugs.gnu.org; 20 Dec 2014 20:57:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 15:57:56 2014
Received: from localhost ([127.0.0.1]:53315 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y2R64-0003NN-CY
	for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 15:57:56 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:51975)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eggert@HIDDEN>) id 1Y2R61-0003NB-Kw
 for 19420 <at> debbugs.gnu.org; Sat, 20 Dec 2014 15:57:54 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
 by smtp.cs.ucla.edu (Postfix) with ESMTP id A00E5A60017;
 Sat, 20 Dec 2014 12:57:52 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
 by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 0+LicdCuOgDM; Sat, 20 Dec 2014 12:57:44 -0800 (PST)
Received: from [192.168.1.9] (pool-71-177-17-123.lsanca.dsl-w.verizon.net
 [71.177.17.123])
 by smtp.cs.ucla.edu (Postfix) with ESMTPSA id EF85939E80BC;
 Sat, 20 Dec 2014 12:57:43 -0800 (PST)
Message-ID: <5495E2C7.1060508@HIDDEN>
Date: Sat, 20 Dec 2014 12:57:43 -0800
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.3.0
MIME-Version: 1.0
To: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>, 
 19420 <at> debbugs.gnu.org
Subject: Re: bug#19420: intermittent segfault using grep -P
References: <5495478C.9090303@HIDDEN>
In-Reply-To: <5495478C.9090303@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 19420
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

I can't reproduce the problem on Ubuntu 14.10 (x86-64) or Fedora 20 (x86-64), 
with either the bundled grep or with GNU grep 2.21.

What locale are you running in?  What's the output of the 'locale' command?

It could be a bug in grep, or in libpcre, or somewhere else.  Ubuntu 14.10 is 
running libpcre3 1:8.35-3ubuntu1.  I vaguely recall that they're doing something 
funky to prevent grep from depending on libpcre while still supporting -P, but I 
don't recall the details.




Information forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Dec 2014 19:14:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 14:14:01 2014
Received: from localhost ([127.0.0.1]:53303 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y2PTT-0007TQ-UQ
	for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 14:14:00 -0500
Received: from eggs.gnu.org ([208.118.235.92]:53169)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2GlG-0007Ux-Fm
 for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 04:55:47 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2GlA-00089d-AV
 for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 04:55:46 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:50729)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2GlA-00089S-0Z
 for submit <at> debbugs.gnu.org; Sat, 20 Dec 2014 04:55:40 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:54870)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2Gl4-0003GY-2S
 for bug-grep@HIDDEN; Sat, 20 Dec 2014 04:55:39 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2Gky-000867-K6
 for bug-grep@HIDDEN; Sat, 20 Dec 2014 04:55:33 -0500
Received: from lb1-smtp-cloud3.xs4all.net ([194.109.24.22]:43181)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <bug-grep-gnu.org@HIDDEN>)
 id 1Y2Gky-00085v-Af
 for bug-grep@HIDDEN; Sat, 20 Dec 2014 04:55:28 -0500
Received: from [192.168.0.130] ([82.95.251.247])
 by smtp-cloud3.xs4all.net with ESMTP
 id VlvQ1p0095M1KXW01lvR8U; Sat, 20 Dec 2014 10:55:26 +0100
Message-ID: <5495478C.9090303@HIDDEN>
Date: Sat, 20 Dec 2014 10:55:24 +0100
From: "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: bug-grep@HIDDEN
Subject: intermittent segfault using grep -P
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 20 Dec 2014 14:13:58 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

When using the following command, *most* of the time I get a 
Segmentation fault (10 out of 16 times):

€ cat grepTxt | grep -P 'b(?:(?!tom).)+'
Segmentation fault (core dumped)

This happens with the  grep version that came with my Linux installation:

€ grep -V
grep (GNU grep) 2.16

I am on:

NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"

But also compiled grep from sources 
(http://ftp.gnu.org/gnu/grep/grep-2.21.tar.xz) with the same problem.

libpcre3:amd64; libpcre3:i386; libpcre3-dev:amd64; libpcrecpp0:amd64 are 
all 1:8.31-2ubuntu2

I tried to reduce the regex and the text as much as possible to still 
reproduce the issue most of the time, unfortunately the text is still 
16893 bytes long. As I don't know if it is OK to attach such a long 
file, I put it on pastebin, but will expire in a month.

http://pastebin.com/download.php?i=jsHskMAA

Please advise.

Kind regards,

JP




Acknowledgement sent to "J.P. Hendrix" <bug-grep-gnu.org@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-grep@HIDDEN. Full text available.
Report forwarded to bug-grep@HIDDEN:
bug#19420; Package grep. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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