Bug 194823 - "bsdgrep -E { /dev/null" core dumps
Summary: "bsdgrep -E { /dev/null" core dumps
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-04 20:22 UTC by Kurt Lidl
Modified: 2017-08-16 17:38 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Lidl freebsd_committer freebsd_triage 2014-11-04 20:22:03 UTC
On my 9.3-RELEASE machine, 'bsdgrep -E { /dev/null' core-dumps.

Noticed on an amd64 machine:

FreeBSD xxx.pix.net 9.3-RELEASE-p3 FreeBSD 9.3-RELEASE-p3 #0: Mon Oct 20 15:08:33 UTC 2014     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

Also happens on a mips64 machine, running HEAD:

FreeBSD xxx.pix.net 11.0-CURRENT FreeBSD 11.0-CURRENT #4 r273585M: Mon Oct 27 19:49:36 UTC 2014     lidl@xxx.pix.net:/usr/obj/usr/src/sys/ERL  mips

And on a sparc64 machine, running 10.1-ish code:

FreeBSD xxx.pix.net 10.1-PRERELEASE FreeBSD 10.1-PRERELEASE #1 r273165: Thu Oct 16 19:30:46 UTC 2014     lidl@xxx.pix.net:/usr/obj/usr/src/sys/GENERIC  sparc64
Comment 1 Kurt Lidl freebsd_committer freebsd_triage 2015-07-01 14:16:08 UTC
I just when through and verified that this problem still occurs on the
latest version of the systems I have running:

mips64:
FreeBSD erl.pix.net 11.0-CURRENT FreeBSD 11.0-CURRENT #8 r284544M: Sat Jun 20 20:33:13 UTC 2015     lidl@erl.pix.net:/usr/obj/usr/src/sys/ERL  mips
lidl@erl-144: bsdgrep -E { /dev/null
[1]    67545 segmentation fault (core dumped)  bsdgrep -E { /dev/null

amd64:
FreeBSD busybox.pix.net 11.0-CURRENT FreeBSD 11.0-CURRENT #49 r284732M: Tue Jun 23 19:25:27 EDT 2015     lidl@busybox.pix.net:/usr/obj/usr/src/sys/BUSYBOX  amd64
root@busybox-131: bsdgrep -E { /dev/null
[1]    88614 segmentation fault (core dumped)  bsdgrep -E { /dev/null

sparc64:
FreeBSD ton.pix.net 10.2-PRERELEASE FreeBSD 10.2-PRERELEASE #1: Tue Jun 30 19:51:35 EDT 2015     root@ton.pix.net:/usr/obj/usr/src/sys/V120  sparc64
$ bsdgrep -E { /dev/null
Segmentation fault (core dumped)
Comment 2 Ed Maste freebsd_committer freebsd_triage 2015-10-14 13:24:52 UTC
FWIW this does not happen on OS X's bsdgrep.
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2016-08-11 06:50:34 UTC
(In reply to Ed Maste from comment #2)
> FWIW this does not happen on OS X's bsdgrep.

It's unfortunate that they don't seem to release their modified sources.  I would like to see that they changed to fix this (and other) issues. :)
Comment 4 Ed Maste freebsd_committer freebsd_triage 2017-02-20 15:37:00 UTC
(In reply to Dimitry Andric from comment #3)

As ngie reports in PR 191086 the Apple grep source is now here: https://opensource.apple.com/source/text_cmds/text_cmds-97/grep/
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2017-02-20 20:14:17 UTC
(In reply to Ed Maste from comment #4)
> (In reply to Dimitry Andric from comment #3)
> 
> As ngie reports in PR 191086 the Apple grep source is now here:
> https://opensource.apple.com/source/text_cmds/text_cmds-97/grep/

IIRC I had seen that before, and there are two notable issues:
* Apple seem to have imported a version from CVS, e.g. their grep.c has: __FBSDID("$FreeBSD: src/usr.bin/grep/grep.c,v 1.16 2012/01/15 17:01:28 eadler Exp $");
* Apple does not use our usr.bin/grep/regex, but their own regex library, for which I do not know the origin.
Comment 6 Conrad Meyer freebsd_committer freebsd_triage 2017-04-05 04:06:17 UTC
Should be fixed in r316495.  Apologies, I was not aware of this PR when I committed Kyle's change.
Comment 7 commit-hook freebsd_committer freebsd_triage 2017-04-21 14:36:24 UTC
A commit references this bug:

Author: emaste
Date: Fri Apr 21 14:36:10 UTC 2017
New revision: 317254
URL: https://svnweb.freebsd.org/changeset/base/317254

Log:
  bsdgrep: add BSD_GREP_FASTMATCH knob for built-in fastmatch

  Bugs have been found in the fastmatch implementation as used in bsdgrep.
  Some have been fixed (r316495) while fixes for others are in review
  (D10098).

  In comparison with the fastmatch implementation, Kyle Evans found that:

  - regex(3)'s performance with literal expressions offers a speed
    improvement over fastmatch

  - regex(3)'s performance, both with simple BREs and EREs, seems to be
    comparable

  The regex implementation was imported in r226035, and the commit message
  reports:

      This is a temporary solution until the whole regex library is
      not replaced so that BSD grep development can continue and the
      backported code gets some review and testing. This change only
      improves scalability slightly, there is no big performance boost
      yet but several minor bugs have been found and fixed.

  Introduce a WITH_/WITHOUT_BSD_GREP_FASTMATCH knob to support testing
  of both approaches.

  PR:		175314, 194823
  Submitted by:	Kyle Evans <kevans91 at ksu.edu>
  Reviewed by:	bdrewery (in part)
  Differential Revision:	https://reviews.freebsd.org/D10282

Changes:
  head/share/man/man5/src.conf.5
  head/share/mk/src.opts.mk
  head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH
  head/usr.bin/grep/Makefile
  head/usr.bin/grep/grep.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/util.c
Comment 8 commit-hook freebsd_committer freebsd_triage 2017-08-16 17:38:47 UTC
A commit references this bug:

Author: kevans
Date: Wed Aug 16 17:38:38 UTC 2017
New revision: 322582
URL: https://svnweb.freebsd.org/changeset/base/322582

Log:
  MFC r317254: bsdgrep: add BSD_GREP_FASTMATCH knob for built-in fastmatch

  Bugs have been found in the fastmatch implementation as used in bsdgrep.
  Some have been fixed (r316495) while fixes for others are in review
  (D10098).

  In comparison with the fastmatch implementation, Kyle Evans found that:

  - regex(3)'s performance with literal expressions offers a speed
    improvement over fastmatch

  - regex(3)'s performance, both with simple BREs and EREs, seems to be
    comparable

  The regex implementation was imported in r226035, and the commit message
  reports:

      This is a temporary solution until the whole regex library is
      not replaced so that BSD grep development can continue and the
      backported code gets some review and testing. This change only
      improves scalability slightly, there is no big performance boost
      yet but several minor bugs have been found and fixed.

  Introduce a WITH_/WITHOUT_BSD_GREP_FASTMATCH knob to support testing
  of both approaches.

  Regenerate src.conf(5) as per the original commit

  PR:		175314, 194823
  Approved by:	emaste (mentor, blanket MFC)

Changes:
_U  stable/11/
  stable/11/share/man/man5/src.conf.5
  stable/11/share/mk/src.opts.mk
  stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH
  stable/11/usr.bin/grep/Makefile
  stable/11/usr.bin/grep/grep.c
  stable/11/usr.bin/grep/grep.h
  stable/11/usr.bin/grep/util.c