From nobody Mon Sep 20 01:13:55 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5A25F17C4F6F for ; Mon, 20 Sep 2021 01:13:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HCRQq1z9nz4RB8 for ; Mon, 20 Sep 2021 01:13:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 251FE26EDA for ; Mon, 20 Sep 2021 01:13:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 18K1DtCY063324 for ; Mon, 20 Sep 2021 01:13:55 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 18K1Dt7w063323 for bugs@FreeBSD.org; Mon, 20 Sep 2021 01:13:55 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 258616] fgrep fails to find string that is present Date: Mon, 20 Sep 2021 01:13:55 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 12.2-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dtucker@dtucker.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N 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.=