[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grep Bug

From: Eric Blake
Subject: Re: Grep Bug
Date: Mon, 13 Dec 2010 10:39:22 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 12/13/2010 09:40 AM, Pedro Faria wrote:
> Hello,
> I was trying to make a regular expression, in mode -P, with grep to take
> every comment in a .c source code. The expression that I use was:
> cat cSource | grep -o -P '/\*(.|\n|\r)*\*/'

[unrelated to your bug report]:

This is a useless use of cat.  You can use

grep -o -P '/\*(.|\n|\r)*\*/' cSource

for the same effect.

> The result of this operation was 'Segmentation fault' (instead of a warning
> or so..), I know that i used a greedy expression, the correct one should be
> '/\*(.|\n|\r)*?\*/' to take the smallest match (it works!). I don't know if
> you consider this a bug or only a user mistake, if it's the latter sorry for
> the waste of time :)

Disclaimer - I'm not an active grep contributor, so you'll probably want
to wait for others to reply as well.  But it would be helpful if you
could provide a backtrace of the code at the point of the segfault.  If
this is a case of causing grep to recurse deeper than the stack bounds
allow, it may be possible to teach grep how to recognize stack overflow
and exit with a more graceful error than a segfault, by using the gnulib
c-stack module.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]