buggrep - Bugs: bug #21342, grep --colour=yes -i...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #21342: grep --colour=yes -i ".*" hangs forever (+patch)

Submitted by:  spiritus <spiritus999>
Submitted on:  Sun 14 Oct 2007 10:22:54 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri 04 Dec 2009 12:21:54 PM UTC, comment #1:

Thank you for the bug report. This bug has been fixed in CVS and
in grep-2.5.4. You may download the latest release from:

ftp://ftp.gnu.org/gnu/grep/

Paolo Bonzini <bonzini>
Sun 14 Oct 2007 10:22:54 PM UTC, original submission:

I have accidently found, that there is a proble 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.

spiritus <spiritus999>

 

Attached Files
file #14142:  grep_colorize_fix.patch added by spiritus999 (649B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bonzini (Posted a comment)
  • -unavailable- added by spiritus999 (Submitted the item)
  • -unavailable- added by spiritus999
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 04 Dec 2009 12:21:54 PM UTCbonziniOpen/ClosedOpen=>Closed
    Mon 15 Oct 2007 06:50:10 PM UTCtaaStatusNone=>Works For Me
      Open/ClosedOpen=>Closed
    Mon 15 Oct 2007 06:46:39 PM UTCtaaStatusNone=>Works For Me
      Open/ClosedOpen=>Closed
    Sun 14 Oct 2007 10:22:54 PM UTCspiritus999Attached File-=>Added grep_colorize_fix.patch, #14142
      Carbon-Copy-=>Added spiritus999

    Back to the top


    Powered by Savane 3.1-cleanup1