Tue 20 Mar 2012 06:23:35 PM UTC, original submission:
Hey. Longtime user, first time posting.
If I pipe data on stdin, and pass '-r' and '--exclude-dir' flags, then I get a segfault. e.g:
$ ls | grep -r --exclude-dir=X pattern
Segmentation fault
My understanding is that both these flags are meaningless when piping in data, so a viable workaround is simply "don't do that." However, for many years I have invoked grep via a command-line alias (or wrapper script) to set a few common options (such as "--exclude-dir=\.git"). This same alias gets used regardless of whether I'm invoking grep on files, or on piped data.
Incidentally, I don't think I can use GREP_OPTIONS to do this because this breaks tools I run which call grep internally.
I compiling from source for grep 2.11.
I'm compiling on OSX, using:
$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
I also see the same beheviour when installing grep using Homebrew (which is also compiling grep v2.11)
The corefiles look like:
$ gdb grep /cores/core.31786
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
...
This GDB was configured as "x86_64-apple-darwin"
...
#0 0x00007fff8897ac00 in strlen ()
(gdb) bt
#0 0x00007fff8897ac00 in strlen ()
#1 0x0000000100015576 in excluded_file_name (ex=0x1001005a0, f=0x0) at exclude.c:445
#2 0x0000000100012305 in grepdir (dir=0x0, stats=0x100048620) at main.c:1364
#3 0x0000000100014048 in main (argc=11, argv=0x7fff5fbff0b8) at main.c:2216
I can supply the corefile or any other info if that helps.
|