I have accidently found, that there is a problem with grep 2.5.1a and early versions having --colour support. It hangs on the following test case: echo test|grep --colour=yes -i ".*". It loops forever in the while-loop at grep-2.5.1a/src/grep.c beginning from line 570: while ((match_offset = (*execute) (ibeg, ilim-ibeg, &match_size, 1)) != (size_t) -1) { char const *b = beg + match_offset; if (b == lim) break; fwrite (beg, sizeof (char), match_offset, stdout); printf ("\33[%sm", grep_color); fwrite (b, sizeof (char), match_size, stdout); fputs ("\33[00m", stdout); beg = b + match_size; ibeg = ibeg + match_offset + match_size; } gdb show that match_offset=0, so b = beg and it and it loops forever, because match_offset != -1 and b != lim. It seems there is a fix for the same problem, but for different situation when (match_icase==0) i.e. grep --colour without switch "-i". Suggested patch attached. Tested with the most recent stable sys-apps/grep-2.5.1a-r1 with the default setting: alias grep='grep --colour=auto'. My original bugreport here: https://savannah.gnu.org/bugs/?21342 Reproducible: Always Steps to Reproduce: echo test|grep --colour=yes -i ".*". Actual Results: grep hangs Expected Results: Normal exit
Created attachment 133477 [details, diff] grep-2.5.1a_colorize_fix.patch
Created attachment 133481 [details, diff] grep-2.5.1a-r2.ebuild
*** This bug has been marked as a duplicate of bug 171776 ***
There is no solution for the bug. grep 2.5.3 is buggy. $ grep -B1 ^KEYWORDS /usr/portage/sys-apps/grep/grep-2.5.3.ebuild # too many test failures -- once those get fixed, we'll ~arch KEYWORDS="" #~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
How about getting my fix for current stable grep 2.5.1a?
(In reply to comment #4) > grep 2.5.3 is buggy. We know that it's buggy. *** This bug has been marked as a duplicate of bug 171776 ***
Please, clarify. There is no solution for the bug because 2.5.3 is hardmasked and 2.5.1a has the bug. Why don't just fix it with my patch https://bugs.gentoo.org/attachment.cgi?id=133477? :(