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)

Submitter:  spiritus <spiritus999>
Submitted:  Sun 14 Oct 2007 10:22:54 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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
  • -email is unavailable- added by bonzini (Posted a comment)
  • -email is unavailable- added by spiritus999 (Submitted the item)
  • -email is unavailable- added by spiritus999
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-12-04 bonzini Open/ClosedOpen Closed
    2007-10-15 taa StatusNone Works For Me
        Open/ClosedOpen Closed
    2007-10-15 taa StatusNone Works For Me
        Open/ClosedOpen Closed
    2007-10-14 spiritus999 Attached File- Added grep_colorize_fix.patch, #14142
        Carbon-Copy- Added spiritus999

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code