Subject: Re: bug#76291: BUG: grep sometimes spits out random garbage in the moddle of results

From: "Dale R. Worley" <[email-masked]>
Date: Wed, 19 Feb 2025 21:02:03 -0500

php fan <[email-masked]> writes:
> I have no idea what triggers this, so I haven't been able to produce a
> minimal reproducing example; and I can't share the actual folder with
> which this happens to me all the time.
>
> Sometimes I use "grep -R" on a folder with several repositories, and
> after a few legitimate results, I get a blob of dozens of lines of
> text, coming from several files, with no indication of the file they
> belong to, and which often don't match the pattern.

One thing to do is to see if the results are reproducible.  So whenever
one of these incidents happens, immediately run the same command again
and see if you get another incident.

Another thing that would help is if the problem is reproducible, run it
again but "tee" it to capture the results in a file.  E.g.

$ grep -R foo | tee /tmp/grep-save

Then you can examine the file with an editor.

Likely the actual output is a set of "lines" from grep's point of view,
but the apparent line breaks are driven by long strings of characters
that don't contain newlines, or perhaps non-ASCII bytes that cause the
display to break lines.

Are the files in these repositories likely to contain compressed text?

Dale