GNU Grep core dump

  • Thread starter Thread starter Deleted member 58333
  • Start date Start date
D

Deleted member 58333

Guest
Dear FreeBSD users,
I get core dump with stock GNU Grep with the following command line :
cat testgrep.txt | grep -i -m1 -A20 Hello
Hello GNU Grep ;-)
Segmentation fault


My system : FreeBSD 12.1-RELEASE-p2 GENERIC amd64

testgrep.txt content :
Code:
Hello GNU Grep ;-)
Fuck GNU Grep !
 
Code:
dice@maelcum:~/test % cat testgrep.txt | grep -i -m1 -A20 Hello
Hello GNU Grep ;-)
Fuck GNU Grep !
dice@maelcum:~/test % uname -a
FreeBSD maelcum.dicelan.home 12.1-STABLE FreeBSD 12.1-STABLE r355710 MAELCUM  amd64

Code:
dice@wintermute:~/test % cat testgrep.txt | grep -i -m1 -A20 Hello
Hello GNU Grep ;-)
Fuck GNU Grep !
dice@wintermute:~/test % uname -a
FreeBSD wintermute.dicelan.home 12.1-RELEASE-p1 FreeBSD 12.1-RELEASE-p1 GENERIC  amd64

Noticed it was still p1, so I did a quick update:
Code:
dice@wintermute:~/test % cat testgrep.txt | grep -i -m1 -A20 Hello
Hello GNU Grep ;-)
Fuck GNU Grep !
dice@wintermute:~/test % uname -a
FreeBSD wintermute.dicelan.home 12.1-RELEASE-p2 FreeBSD 12.1-RELEASE-p2 GENERIC  amd64
 
Code:
$ cat testgrep.txt | /usr/bin/bsdgrep -i -m1 -A20 Hello
Hello Gnu Grep ;-)
No core dump with BSD grep and I haven't got the same output than yours.
 
They seem to behave differently:
Code:
dice@maelcum:~/test % cat testgrep.txt | bsdgrep -i -m1 -A20 Hello
Hello GNU Grep ;-)
dice@maelcum:~/test % cat testgrep.txt | grep -i -m1 -A20 Hello
Hello GNU Grep ;-)
Fuck GNU Grep !
 
I'm seeing the same grep segmentation fault here.
Code:
% uname -an
FreeBSD lt1.jimmy.localnet 12.1-STABLE FreeBSD 12.1-STABLE r357231 GENERIC  amd64
 
Got the same problem with 2 machines with same release with ZFS.
When running a virtualbox VM with UFS, I haven't got the problem.
I will try to create a VM with ZFS for test.
 
I'm seeing the same grep segmentation fault here.
Code:
% uname -an
FreeBSD lt1.jimmy.localnet 12.1-STABLE FreeBSD 12.1-STABLE r357231 GENERIC  amd64
ZFS ?
 
Code:
grep (GNU grep) 2.5.1-FreeBSD
Interesting that the segfault doesn't happen when the requested max match count is increased to more than 1.
 
i can't reproduce it on clean install under VM under csh

MD5 (/usr/bin/grep) = 989babfef5c0454b790bd2c9359fa686

grep (GNU grep) 2.5.1-FreeBSD

Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
Got the problem with login shell but not when using su username from root.
So got the problem with su -l username
 
I get the problem with my locale setting in .login_conf :
Code:
me:\
    :charset=UTF-8:\
    :lang=fr_FR.UTF-8:
 
What is the best way to get BSD grep by default ?
Rename /usr/bin/grep and symlink to BSD grep ?
Does the system needs GNU grep ?
or just for me with an alias ?
 
Whatever shell I am using, GNU grep is working with C locale :
Code:
% setenv LC_ALL C
% cat testgrep.txt | grep -i -m1 -A20 Hello
Hello GNU Grep ;-)
Fuck GNU Grep !
 
What is the best way to get BSD grep by default ?
Rename /usr/bin/grep and symlink to BSD grep ?
Build from source and set WITH_BSD_GREP in /etc/src.conf:
Code:
     WITH_BSD_GREP
             Install BSD-licensed grep as '[ef]grep' instead of GNU grep.
Caveat emptor: Last time I tried this several ports failed to build with really weird errors. Same ports built fine with the GNU grep. This was quite some time ago, this issue may have been fixed in the mean time. But it's something to be aware off.
 
Build from source and set WITH_BSD_GREP in /etc/src.conf:
Code:
     WITH_BSD_GREP
             Install BSD-licensed grep as '[ef]grep' instead of GNU grep.
I prefer to stick with GENERIC and binary updates. No time and resources to build world.
 
Back
Top