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   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to