Date: Mon, 20 Sep 2021 01:13:55 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 258616] fgrep fails to find string that is present Message-ID: <bug-258616-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D258616 Bug ID: 258616 Summary: fgrep fails to find string that is present Product: Base System Version: 12.2-STABLE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: dtucker@dtucker.net Created attachment 228028 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D228028&action= =3Dedit known_hosts file demonstrating fgrep problem I think I've discovered a case where fgrep fails to find a string that is in fact present in the input file. I have been seeing intermittent test failures in OpenSSH's regress tests on= at least FreeBSD 12.2 and NetBSD 9 (which seems to be based on FreeBSD's code)= .=20 The test fails maybe 1 in 100 times when fgrep fails to match a string (an = SSH host key in this case) that is in the input file. It seems to be (a) data-dependent and (b) consistent. I captured one of the failure cases (attached), and if I select the key from the file with awk th= en fgrep for it, fgrep does not find it: $ uname -a FreeBSD fbsd12 12.2-RELEASE-p3 FreeBSD 12.2-RELEASE-p3 GENERIC amd64 $ fgrep $(awk '$2=3D=3D"ssh-rsa"{print $3}' known_hosts) known_hosts; echo = $? 1 $ grep -F $(awk '$2=3D=3D"ssh-rsa"{print $3}' known_hosts) known_hosts; ech= o $? 1 but the equivalent awk will find it: $ a=3D$(awk '$2=3D=3D"ssh-rsa"{print $3}' known_hosts)=20=20=20=20=20=20=20= =20=20=20=20 $ awk '$3=3D=3D"'$a'"' known_hosts localhost-with-alias ssh-rsa [key elided] and if I reduce the size of the file fgrep then also works: $ grep ssh-rsa known_hosts >known_hosts2 $ fgrep $(awk '$2=3D=3D"ssh-rsa"{print $3}' known_hosts2) known_hosts2; ech= o $? localhost-with-alias ssh-rsa [key elided] 0 Deleting the first few lines from the file will also make it work. Further weirdness: I built grep from the 12.2 branch it worked as expected: $ ./grep -F $(awk '$2=3D=3D"ssh-rsa"{print $3}' known_hosts) known_hosts; e= cho $? localhost-with-alias ssh-rsa [key elided] 0 Same file works as expected on at least Linux and OpenBSD. One of the other developers reproduced this and reduced the size of the test case which I wi= ll also attach. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-258616-227>