Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 98935

Summary: grep -P producing segmentation faults
Product: Gentoo Linux Reporter: Loren J. Gibson <ljgibson>
Component: [OLD] Core systemAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
URL: http://forums.gentoo.org/viewtopic-t-359008.html
Whiteboard:
Package list:
Runtime testing required: ---

Description Loren J. Gibson 2005-07-13 16:30:50 UTC
grep -P with certain patterns may cause segfaults. I do not know the exact set
of conditions under which the crash will occur, but I have discovered one
example. I'm using grep-2.5.1-r7, compiled with +nls and +pcre flags set.

Reproducible: Always
Steps to Reproduce:
1. Input a two-line data file which looks like this (fewer or more similarly
structured lines does not affect the outcome):
  230  0 0.000000  58 0 0.000000
  230  1 0.000000  58 0 0.000000
2. Execute the following:
grep -P '^\s*\d+\s+\d+\s+0\.000000\s+\d+\s+\d+\s+0\.000000\s*$' filename.txt
where "filename.txt" is the file containing the data shown in step 1.


Actual Results:  
Output is as follows:
  230  0 0.000000  58 0 0.000000
  230  1 0.000000  58 0 0.000000
Segmentation fault


Expected Results:  
Output should be (assuming my pattern is correct):
  230  0 0.000000  58 0 0.000000
  230  1 0.000000  58 0 0.000000

Segfault won't occur if the anchor ($) is dropped from the end of the pattern
supplied as the argument to grep. However, if the pattern is simplified to
'^.*$' grep will not segfault even with $ at the end of the pattern.

grep 2.5.1 on my RH 9 system exhibits same behavior.


emerge info output is as follows:

Gentoo Base System version 1.6.12
Portage 2.0.51.22-r1 (default-linux/x86/2005.0, gcc-3.3.5-20050130,
glibc-2.3.4.20041102-r1, 2.6.12-gentoo-r4 i686)
=================================================================
System uname: 2.6.12-gentoo-r4 i686 Pentium III (Coppermine)
dev-lang/python:     2.3.5
sys-apps/sandbox:    1.2.10
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.5
sys-devel/binutils:  2.15.92.0.2-r10
sys-devel/libtool:   1.5.18-r1
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=i686 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env
/usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3.4/env
/usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config
/usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config
/usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/
/usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=i686 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org
http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 X acpi alsa apm arts avi berkdb bitmap-fonts cdr crypt cups curl doc
dvd eds emboss encode esd exif fam foomaticdb fortran gd gdbm gif gnome gpm
gstreamer gtk gtk2 guile imagemagick imlib java javascript jpeg libg++ libwww
mad mbox mikmod motif mozilla mp3 mpeg ncurses nls odbc ogg oggvorbis opengl oss
pam pdflib perl plotutils png postgres python qt quicktime readline samba sdl
spell sse ssl svga tcltk tcpd tetex tiff truetype truetype-fonts type1-fonts
vorbis wmf xml xml2 xmms xv zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTDIR_OVERLAY
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2005-07-13 16:41:26 UTC
Please, try 2.5.1-r8 and reopen if it still segfaults.

*** This bug has been marked as a duplicate of 95495 ***