Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 514454 - sys-apps/grep-2.16[pcre] with dev-libs/libpcre[-jit]: segmentation fault in match (...) at pcre_exec.c:2621
Summary: sys-apps/grep-2.16[pcre] with dev-libs/libpcre[-jit]: segmentation fault in m...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-22 13:56 UTC by Alex Efros
Modified: 2022-05-03 23:57 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
test.swp (test.swp,12.00 KB, application/octet-stream)
2014-06-22 13:56 UTC, Alex Efros
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Efros 2014-06-22 13:56:37 UTC
Created attachment 379406 [details]
test.swp

$ LANG=en_US.UTF-8 grep -P -i k test.swp 
Segmentation fault

test.swp attached (it's Vim's .swp file of small perl script).
With LANG= there is no segfault, probably because PCRE don't try to do some unicode-related thing.

[ebuild   R    ] sys-apps/grep-2.16  USE="nls pcre -static" 0 kB
[ebuild   R    ] dev-libs/libpcre-8.33:3  USE="bzip2 cxx readline recursion-limit (unicode) zlib -jit -libedit -pcre16 -pcre32 -static-libs" 0 kB


Portage 2.2.8-r1 (hardened/linux/amd64, gcc-4.7.3, glibc-2.17, 3.14.5-hardened-r2_nofb x86_64)
=================================================================
System uname: Linux-3.14.5-hardened-r2_nofb-x86_64-Intel-R-_Core-TM-_i7-2600K_CPU_@_3.40GHz-with-gentoo-2.2
KiB Mem:     8162032 total,    676008 free
KiB Swap:    4200960 total,   4198584 free
Timestamp of tree: Sun, 22 Jun 2014 06:15:02 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.6, 3.3.3
dev-util/cmake:           2.8.12.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo perl-experimental-snapshots gamerlay powerman local
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /opt/upsmon-usb/EXT/DownOS /opt/upsmon-usb/EXT/JSystem /service /usr/inferno/keydb /usr/inferno/lib /usr/inferno/services /usr/share/config /usr/share/easy-rsa /usr/share/gnupg/qualified.txt /var/log /var/qmail/alias /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage-distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --autounmask-write --backtrack=15"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict test unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="http://gentoo.iteam.net.ua/ http://tux.rainside.sk/gentoo/ http://trumpetti.atm.tut.fi/gentoo/ http://gentoo.inode.at/"
LANG="ru_RU.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage-packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--exclude ChangeLog --delete-excluded"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/perl-experimental-snapshots /var/lib/layman/gamerlay /var/lib/layman/powerman /usr/local/portage"
SYNC="rsync://rsync.ua.gentoo.org/gentoo-portage"
USE="X a52 aac alac alsa amd64 avx bash-completion berkdb bzip2 caps cdda cddb cli cracklib crypt cxx dbus dri drm dts dvb dvd egl flac fontconfig gallium gdbm gif gnutls gpg hardened iconv icu id3tag idn ipv6 jpeg jpeg2k justify libnotify mac mad matroska mbox mmx mng modules mp3 mpeg multilib musepack mysql ncurses network-cron nls nptl nsplugin ogg opengl openmp openvg pam pax_kernel pcre perl png qt3support readline session spell sse sse2 sse3 sse4_1 sse4_2 ssl ssse3 svg tcpd theora tiff truetype unicode urandom vdpau vim-syntax vorbis wavpack x264 xattr xosd xtpax xv xvid xvmc zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="log_config vhost_alias autoindex alias rewrite dir deflate filter mime negotiation auth_basic authn_file authz_host authz_user authz_groupfile cgi actions headers env setenvif" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en ru" NGINX_MODULES_HTTP="access auth_basic autoindex browser charset empty_gif fastcgi geo gzip limit_conn limit_req map memcached proxy referer rewrite scgi split_clients ssi upstream_ip_hash userid uwsgi fancyindex" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" QEMU_SOFTMMU_TARGETS="x86_64 i386" QEMU_USER_TARGETS="x86_64 i386" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="nvidia nouveau" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, USE_PYTHON
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-23 01:42:38 UTC
(In reply to Alex Efros from comment #0)
> [ebuild   R    ] dev-libs/libpcre-8.33:3  USE="bzip2 cxx readline
> recursion-limit (unicode) zlib -jit -libedit -pcre16 -pcre32 -static-libs" 0
> kB

I had no problems with these USE flags:

  [ebuild   R    ] dev-libs/libpcre-8.33:3  USE="bzip2 cxx jit pcre16 readline
  recursion-limit (unicode) zlib -libedit -pcre32 -static-libs" 0 kB

When matching yours, I get:

#0  0x00007ffff7f98b9b in match (eptr=0x43701e "werman", ecode=0x436513 "\020\tGr", mstart=0x437018 "\374J", offset_top=2, 
    md=<optimized out>, eptrb=0x0, rdepth=0) at pcre_exec.c:2621
        cp = <optimized out>
        prop = <optimized out>
        rrc = <optimized out>
        i = <optimized out>
        c = 167775279
        utf = 1
        minimize = 0
        possessive = 0
        caseless = <optimized out>
        condcode = <optimized out>
        charptr = <optimized out>
        callpat = <optimized out>
        data = <optimized out>
        next = <optimized out>
        pp = <optimized out>
        prev = <optimized out>
        saved_eptr = <optimized out>
        new_recursive = {prevrec = 0x0, group_num = 0, offset_save = 0x0, saved_max = 0, saved_capture_last = 0, 
          subject_position = 0x0}
        cur_is_word = <optimized out>
        condition = <optimized out>
        prev_is_word = <optimized out>
        prop_type = <optimized out>
        prop_value = 0
        prop_fail_result = 0
        oclength = <optimized out>
        occhars = "\000\000\000\000\000"
        codelink = <optimized out>
        ctype = <optimized out>
        length = <optimized out>
        max = <optimized out>
        min = <optimized out>
        number = <optimized out>
        offset = <optimized out>
        op = 16
        save_capture_last = <optimized out>
        save_offset1 = <optimized out>
        save_offset2 = <optimized out>
        save_offset3 = <optimized out>
        stacksave = {0, 0, 1, 0, 4, 0, 2147215763, 0, -134733744, 32767, -136427936, 32767, -15328, 32767, 33550246, 0, -1, 0, 
          -134729328, 32767, -134726932, 32767, 0, 0, -15312, 32767, 8387561, 0, -134729328, 32767}
        newptrb = {epb_prev = 0x0, epb_saved_eptr = 0x0}
#1  0x00007ffff7fa901f in pcre_exec (argument_re=0x4364d0, extra_data=0x436530, subject=subject@entry=0x437000 "b0VIM 7.4", 
    length=<optimized out>, start_offset=start_offset@entry=0, options=options@entry=8192, offsets=offsets@entry=0x7fffffffc590, 
    offsetcount=offsetcount@entry=300) at pcre_exec.c:6976
---Type <return> to continue, or q <return> to quit---
        save_end_subject = 0x43a000 "\n"
        new_start_match = <optimized out>
        rc = <optimized out>
        ocount = 300
        arg_offset_max = 200
        newline = <optimized out>
        using_temporary_offsets = <optimized out>
        anchored = <optimized out>
        startline = <optimized out>
        firstline = <optimized out>
        utf = 1
        has_first_char = 0
        has_req_char = 0
        first_char = 0 '\000'
        first_char2 = 0 '\000'
        req_char = 0 '\000'
        req_char2 = 0 '\000'
        match_block = {match_call_count = 2, match_limit = 10000000, match_limit_recursion = 8192, offset_vector = 0x7fffffffc590, 
          offset_end = 300, offset_max = 200, nltype = 0, nllen = 1, name_count = 0, name_entry_size = 0, skip_arg_count = 0, 
          ignore_skip_arg = 0, name_table = 0x436510 "}", nl = "\n\253\377", <incomplete sequence \367>, lcc = 0x436080 "", 
          fcc = 0x436180 "", ctypes = 0x4363c0 "\200", notbol = 0, noteol = 0, utf = 1, jscript_compat = 0, use_ucp = 0, 
          endonly = 0, notempty = 0, notempty_atstart = 0, hitend = 0, bsr_anycrlf = 0, hasthen = 0, start_code = 0x436510 "}", 
          start_subject = 0x437000 "b0VIM 7.4", end_subject = 0x43a000 "\n", start_match_ptr = 0x437018 "\374J", 
          end_match_ptr = 0x43a001 "", start_used_ptr = 0x437018 "\374J", partial = 0, end_offset_top = 0, capture_last = 0, 
          start_offset = 0, match_function_type = 0, eptrchain = 0x0, eptrn = -134728272, recursive = 0x0, callout_data = 0x0, 
          mark = 0x0, nomatch_mark = 0x0, once_target = 0x7fffffffc590 "\377\377\377\377\377\377\377\377"}
        md = 0x7fffffffc400
        tables = <optimized out>
        start_bits = 0x0
        start_match = <optimized out>
        end_subject = <optimized out>
        start_partial = 0x0
        match_partial = 0x0
        req_char_ptr = 0x436fff "\nb0VIM 7.4"
        study = 0x436570
        re = 0x4364d0
#2 [...]

Specifically, with USE=-jit I get segmentation faults.
Comment 2 Alex Efros 2014-06-23 08:01:44 UTC
(In reply to Jeroen Roovers from comment #1)
> Specifically, with USE=-jit I get segmentation faults.

Yeah, enabliing jit fix this, but that's not an option for me - I'm on hardened, and enabliing jit mean I'll have to "paxmark m" all binaries linked with libpcre.
Comment 3 Larry the Git Cow gentoo-dev 2022-05-03 23:57:56 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=19c92a966c7f9b03da46dc047e4655e5e95aed30

commit 19c92a966c7f9b03da46dc047e4655e5e95aed30
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-05-03 23:56:43 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-05-03 23:57:07 +0000

    sys-apps/grep: add 3.7_p20220425 (unkeyworded).
    
    Notably switches to libpcre2 (yay). Pre-release for testing.
    
    Bug: https://bugs.gentoo.org/514454
    Bug: https://bugs.gentoo.org/569816
    Bug: https://bugs.gentoo.org/641186
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/grep/Manifest                  |  2 +
 sys-apps/grep/grep-3.7_p20220425.ebuild | 72 +++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)