Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 616564 - >=app-antivirus/clamav-0.99.2-r1 compiles against wrong libpcre version which leads to seg fault
Summary: >=app-antivirus/clamav-0.99.2-r1 compiles against wrong libpcre version which...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Antivirus Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-25 10:30 UTC by Christian Roessner
Modified: 2017-12-07 15:29 UTC (History)
11 users (show)

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


Attachments
works well on my laptop (ok_clamav-0.99.2-r1_20170501-053133.log,749.03 KB, text/x-log)
2017-09-13 03:48 UTC, giskard
Details
segment fault on another pc (segfault_clamav-0.99.2-r1_20170613-044007.log,748.99 KB, text/x-log)
2017-09-13 03:50 UTC, giskard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Roessner 2017-04-25 10:30:27 UTC
For some reason, clamav stopped working. I have created a coredump and back traced the problem:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000385c359c76c in _pcre2_memctl_malloc_8 (size=size@entry=72, memctl=memctl@entry=0x3c00000000)
    at /var/tmp/portage/dev-libs/libpcre2-10.23/work/pcre2-10.23/src/pcre2_context.c:89
89	void *yield = (memctl == NULL)? malloc(size) :

I tested pcre2 stable and unstable (~amd64 keyword). No difference.

It currently only affects clamav. All other software using pcre2 seems to run fine. So I do not know, if pcre2 or clamav itself is the problem. I keep the coredump, so I can dive deeper in it, if you tell me how :)

I tested clamav 0.99.x (Unfortunately, 0.98.x does not compile anymore, as it tell zlib would be old and recommends version greater than 1.2.2. But I have 1.2.11 (but this would be another report).

So none of the 0.99.x version run anymore.

Thanks

Christian

emerge --info clamav
Portage 2.3.3 (python 2.7.12-final-0, hardened/linux/amd64/no-multilib, gcc-5.4.0, glibc-2.23-r3, 4.8.17-hardened-r2 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.8.17-hardened-r2-x86_64-Intel-R-_Xeon-R-_CPU_L5640_@_2.27GHz-with-gentoo-2.3
KiB Mem:    16430276 total,   7799572 free
KiB Swap:    2097148 total,   2097148 free
Timestamp of repository gentoo: Mon, 24 Apr 2017 21:15:01 +0000
sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1
ccache version 3.2.4 [enabled]
app-shells/bash:          4.3_p48-r1::gentoo
dev-lang/perl:            5.24.1-r1::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo
dev-util/ccache:          3.2.4::gentoo
dev-util/cmake:           3.7.2::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.24.2::gentoo
sys-apps/sandbox:         2.10-r3::gentoo
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.15::gentoo
sys-devel/binutils:       2.26.1::gentoo
sys-devel/gcc:            5.4.0-r3::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r3::gentoo
Repositories:

gentoo
    location: /misc/portage
    sync-type: rsync
    sync-uri: rsync://rsync.europe.gentoo.org/gentoo-portage
    priority: -1000

croessner
    location: /usr/local/portage
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/stunnel/stunnel.conf /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --with-bdeps=y --binpkg-respect-use=y --binpkg-changed-deps=y --usepkg=y --rebuilt-binaries=y --rebuilt-binaries-timestamp=20140405050000"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs ccache compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://de-mirror.org/gentoo/ rsync://de-mirror.org/gentoo/"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/misc/packages"
PORTAGE_CONFIGROOT="/"
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 --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl adns aio amd64 bacula-clientonly bacula-console bash-completion berkdb bindist btrfs bzip2 caps cli cracklib crypt curl cxx device-mapper dri gdbm hardened iconv ipv6 justify logrotate loop-aes lzo mmap mmx modules ncurses nls nptl nscd ntp openmp openssl pam pax_kernel pcre pie readline seccomp session sse sse2 ssl ssp tcpd threads unicode urandom vim-syntax xattr xtpax 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="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" L10N="de en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="de en" NGINX_MODULES_HTTP="access auth_basic autoindex browser charset dav empty_gif fancyindex fastcgi geo gzip headers_more limit_conn limit_req map memcached proxy referer rewrite scgi spdy split_clients ssi upstream_ip_hash userid uwsgi" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" 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:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

app-antivirus/clamav-0.99.2-r1::gentoo was built with the following:
USE="bzip2 clamdtop iconv ipv6 -libressl -metadata-analysis-api -milter (-selinux) -static-libs (-uclibc)"
CFLAGS="-O2 -pipe -g"
CXXFLAGS="-O2 -pipe -g"
Comment 1 Christian Roessner 2017-04-25 10:36:07 UTC
Just found bt full :) Hope somebody understand this :)


#0  0x00000385c359c76c in _pcre2_memctl_malloc_8 (size=size@entry=72, memctl=memctl@entry=0x3c00000000)
    at /var/tmp/portage/dev-libs/libpcre2-10.23/work/pcre2-10.23/src/pcre2_context.c:89
        newmemctl = <optimized out>
        yield = <optimized out>
#1  0x00000385c359c994 in pcre2_match_context_create_8 (gcontext=0x3c00000000)
    at /var/tmp/portage/dev-libs/libpcre2-10.23/work/pcre2-10.23/src/pcre2_context.c:183
        mcontext = <optimized out>
#2  0x00000385c56e3117 in cli_pcre_compile (pd=0x385b9d2a098, match_limit=10000, match_limit_recursion=5000, options=0,
    opt_override=0) at regex_pcre.c:152
        errornum = 100
        erroffset = 0
        gctx = 0x3c00000000
        cctx = 0x3cd3c97170
#3  0x00000385c56e1c94 in cli_pcre_build (root=0x385c2157338, match_limit=10000, recmatch_limit=5000, dconf=0x385c64933c4)
    at matcher-pcre.c:444
        i = 0
        ret = -1038781640
        pm = 0x385b9d2a078
        disable_all = 0
#4  0x00000385c55a04ad in cl_engine_compile (engine=0x3cd3c368a0) at readdb.c:5109
        i = 0
        ret = 0
        root = 0x385c2157338
#5  0x0000003cd019f1c8 in main (argc=1, argv=0x3c7fb7fab68) at clamd.c:632
        engine = 0x3cd3c368a0
        opt = 0x3cd3c11ab0
        user = 0x385c529ad00
        sa = {__sigaction_handler = {sa_handler = 0x1, sa_sigaction = 0x1}, sa_mask = {__val = {0 <repeats 16 times>}},
          sa_flags = 0, sa_restorer = 0x0}
        rlim = {rlim_cur = 88, rlim_max = 3869765533760}
        currtime = 1493115037
        dbdir = 0x3cd3c0f0b0 "/var/lib/clamav"
        cfgfile = 0x3cd3c0e690 "/etc/clamd.conf"
        pua_cats = 0x0
        pt = 0x3cd3c12a70 "clamav"
        ret = 0
        tcpsock = 1
        localsock = 0
        min_port = 1024
        max_port = 2048
        sigs = 4297621
        lsockets = 0x0
        nlsockets = 0
        dboptions = 8202
        i = 96
        j = 1
        num_fd = 0
        sb = {st_dev = 4, st_ino = 1, st_nlink = 269, st_mode = 16749, st_uid = 0, st_gid = 10, __pad0 = 0, st_rdev = 0,
          st_size = 0, st_blksize = 1024, st_blocks = 0, st_atim = {tv_sec = 1493054103, tv_nsec = 449250339}, st_mtim = {
            tv_sec = 1493054103, tv_nsec = 449250339}, st_ctim = {tv_sec = 1493054103, tv_nsec = 449250339},
          __glibc_reserved = {0, 0, 0}}
Comment 2 Christian Roessner 2017-04-25 12:49:28 UTC
I finally found the source of the problem:

If you have installed a version of dev-libs/libpcre2, too, on the system, clamav finds the pcre2 version while running through the configure call and builds against this lib. Unfortunately this seems to be buggy at the moment, what you can see in my report above.

But: If you compile it really against libpcre (not pcre2!), it works.

Someone needs to fix the ebuild to make sure that really libpcre is picked as wanted by DEPEND.

Even adding --with-pcre does not solve the problem. Maybe also a configure patch is needed or some other fix :)
Comment 3 Vladimir Datsevich 2017-05-20 17:50:07 UTC
The same here.

~amd64, libpcre2 pulled in by rspamd, and clamd segfaulting.
Comment 4 Vladimir Datsevich 2017-06-22 09:18:29 UTC
Any news?
Comment 5 Christian Roessner 2017-06-23 08:44:20 UTC
(In reply to bgo from comment #4)
> Any news?

I solved it for me like this:

remove libpcre2 temporarily
re-emerge clamav
reinstall libpcre2

At least this is a workaround for me. But it needs fixing clamav here...
Comment 6 Attila Tóth 2017-06-23 08:52:23 UTC
(In reply to Christian Roessner from comment #5)
> (In reply to bgo from comment #4)
> > Any news?
> 
> I solved it for me like this:
> 
> remove libpcre2 temporarily
> re-emerge clamav
> reinstall libpcre2
> 
> At least this is a workaround for me. But it needs fixing clamav here...

The above mentioned workaround also works for me...
Comment 7 giskard 2017-09-13 03:48:22 UTC
Created attachment 494290 [details]
works well on my laptop
Comment 8 giskard 2017-09-13 03:50:33 UTC
Created attachment 494292 [details]
segment fault on another pc
Comment 9 giskard 2017-09-13 03:55:45 UTC
(In reply to Christian Roessner from comment #5)
> (In reply to bgo from comment #4)
> > Any news?
> 
> I solved it for me like this:
> 
> remove libpcre2 temporarily
> re-emerge clamav
> reinstall libpcre2
> 
> At least this is a workaround for me. But it needs fixing clamav here...

thanks a lot!

it also solved my problem temporary!

however my laptop have the same version of:
 app-antivirus/clamav-0.99.2-r1
 dev-libs/libpcre-8.41
 dev-libs/libpcre2-10.30

I don't know how to debug but hope the build log will do some help
Comment 10 giskard 2017-09-13 03:57:02 UTC
(In reply to Christian Roessner from comment #5)
> (In reply to bgo from comment #4)
> > Any news?
> 
> I solved it for me like this:
> 
> remove libpcre2 temporarily
> re-emerge clamav
> reinstall libpcre2
> 
> At least this is a workaround for me. But it needs fixing clamav here...

thanks a lot!

it also solved my problem temporary!

however my laptop have the same version of:
 app-antivirus/clamav-0.99.2-r1
 dev-libs/libpcre-8.41
 dev-libs/libpcre2-10.30
and clamav is linked to /usr/lib64/libpcre2-8.so.0, and it works fine

I don't know how to debug but hope the build log will do some help
Comment 11 Guillaume REMBERT 2017-10-16 20:46:47 UTC
Problem is still there / confirmed for me also... Temp fix / workaround described here works fine but clamav package is not stable yet
Comment 12 Victor Kustov 2017-11-28 15:35:48 UTC
seems problem linked
https://bugs.gentoo.org/638932
Comment 13 Marcio H Zuchini 2017-11-30 14:31:06 UTC
(In reply to Christian Roessner from comment #5)
> (In reply to bgo from comment #4)
> > Any news?
> 
> I solved it for me like this:
> 
> remove libpcre2 temporarily
> re-emerge clamav
> reinstall libpcre2
> 
> At least this is a workaround for me. But it needs fixing clamav here...

Same here (Sabayon Linux):
-- Unit clamd.service has begun starting up.
Nov 30 12:09:02 calvin kernel: clamd[27875]: segfault at 55ac00000010 ip 00007f1ab23ff67c sp 00007ffc13eff200 error 4 in libpcre2-8.so.0.6.0[7f1ab23ef000+83000]
Nov 30 12:09:02 calvin systemd[1]: clamd.service: Control process exited, code=killed status=11
Nov 30 12:09:02 calvin systemd[1]: Failed to start Generic ClamAV scanner daemon.
-- Subject: Unit clamd.service has failed

Unfortunately, I couldn't remove pcre2 because it has a lot of packages depending on it...
Seems I'll have to wait for a Clamav patch.

Best regards,
Comment 14 Attila Tóth 2017-11-30 16:05:25 UTC
(In reply to Victor Kustov from comment #12)
> seems problem linked
> https://bugs.gentoo.org/638932

Referenced bug's patch solves the segfault for me. This bug might be taken as a duplicate.
Comment 15 Larry the Git Cow gentoo-dev 2017-12-07 15:29:04 UTC
The bug has been closed via the following commit(s):

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

commit ed2ec9f4ebd6b7cf6c8bcbf06fcbb46d826d6d01
Author:     Craig Andrews <candrews@gentoo.org>
AuthorDate: 2017-11-30 16:19:34 +0000
Commit:     Craig Andrews <candrews@gentoo.org>
CommitDate: 2017-12-07 15:28:48 +0000

    app-antivirus/clamav: Fix SIGSEGV on 64bit archs
    
    Suggested-by: Jiří Moravec <qjim@volny.cz>
    Bug: https://bugzilla.clamav.net/show_bug.cgi?id=11965
    Closes: https://bugs.gentoo.org/638932
    Closes: https://bugs.gentoo.org/616564
    Closes: https://github.com/gentoo/gentoo/pull/6358
    Package-Manager: Portage-2.3.16, Repoman-2.3.6

 app-antivirus/clamav/Manifest                      |   2 +-
 app-antivirus/clamav/clamav-0.99.2-r2.ebuild       | 159 +++++++++++++++++++++
 .../clamav-0.99.2-pcre2-compile-erroffset.patch    |  12 ++
 3 files changed, 172 insertions(+), 1 deletion(-)