Bug 239279 - grep . /dev/zero hangs system
Summary: grep . /dev/zero hangs system
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.0-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: crash, needs-qa
Depends on:
Blocks: 230332
  Show dependency treegraph
 
Reported: 2019-07-18 12:33 UTC by AlnXpr
Modified: 2024-08-08 13:42 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description AlnXpr 2019-07-18 12:33:11 UTC
Hello!
I discovery crytical bug.
Any user can use command grep and to bring system to slow as halting.
Command: grep . /dev/zero
Testing system: FreeBSD freebsd 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2019-07-18 15:38:05 UTC
This just causes grep to consume all of the system's memory and swap space.  On my system the OOM killer kicks in and kills grep.
Comment 2 AlnXpr 2019-07-18 15:56:04 UTC
Mark Johnston, may be need tested stable version, i tested this version: FreeBSD freebsd 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64

https://dropmefiles.com/vu7hI
Comment 3 AlnXpr 2019-07-25 11:16:12 UTC
Mark Johnston, You not indicated your version and not answered my question.

Question (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239279#c1):
> Mark Johnston, may be need tested stable version, i tested this version: FreeBSD freebsd 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2019-07-26 14:57:48 UTC
(In reply to AlnXpr from comment #2)
I tested on -CURRENT.  Again, however, any program is by default allowed to consume system memory and force swapouts.  Does your system recover after some time, or do you need a reboot in order to recover?
Comment 5 AlnXpr 2019-07-29 06:15:20 UTC
(In reply to Mark Johnston from comment #4)
No, system not restore.
From restore needed do hard reboot pressed on reset button.
Comment 6 Wolfram Schneider freebsd_committer freebsd_triage 2024-04-29 07:50:34 UTC
I can confirm that the problem still exists on 15-CURRENT. bsdgrep eats all memory until killed by the kernel:

$ grep . /dev/zero
Killed


gnugrep and ripgrep don't have this memory problem, they just run in an endless loop as expected.
Comment 7 Ed Maste freebsd_committer freebsd_triage 2024-08-08 13:42:50 UTC
kib@ pointed out on IRC that grep is trying to read in a whole line, so memory use will grow without bound given input without a newline