Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 657060 - media-libs/opencv-3.4.1-r1 with sys-devel/gcc-8.1.0-r3 - ...work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp:424:5: internal compiler error: Segmentation fault
Summary: media-libs/opencv-3.4.1-r1 with sys-devel/gcc-8.1.0-r3 - ...work/opencv-3.4.1...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://gcc.gnu.org/PR86871
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-01 18:57 UTC by Johannes Hirte
Modified: 2019-02-23 17:23 UTC (History)
5 users (show)

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


Attachments
build.log (build.log,96.61 KB, text/plain)
2018-06-01 19:00 UTC, Johannes Hirte
Details
build-abi_x86_64.amd64.log (build-abi_x86_64.amd64.log,94.80 KB, text/plain)
2018-06-01 19:01 UTC, Johannes Hirte
Details
reduced testcase (calibinit.ii,796 bytes, text/plain)
2018-08-06 10:45 UTC, Johannes Hirte
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Hirte 2018-06-01 18:57:21 UTC
media-libs/opencv fails to compile with sys-devel/gcc-8.1.0-r3:

[ 74%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/calibinit.cpp.o
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp: In function ‘int icvAddOuterQuad(CvCBQuad*, CvCBQuad**, int, CvCBQuad**, int, CvCBCorner**, int)’:
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp:956:52: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct CvCBCorner’; use assignment or value-initialization instead [-Wclass-memaccess]
                 memset( corner, 0, sizeof(*corner) );
                                                    ^
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp:113:8: note: ‘struct CvCBCorner’ declared here
 struct CvCBCorner
        ^~~~~~~~~~
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp: In function ‘int icvGenerateQuads(CvCBQuad**, CvCBCorner**, CvMemStorage*, const cv::Mat&, int, int*)’:
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp:1844:48: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct CvCBCorner’; use assignment or value-initialization instead [-Wclass-memaccess]
             memset( corner, 0, sizeof(*corner) );
                                                ^
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp:113:8: note: ‘struct CvCBCorner’ declared here
 struct CvCBCorner
        ^~~~~~~~~~
during GIMPLE pass: vect
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp: In function ‘int cvFindChessboardCorners(const void*, CvSize, CvPoint2D32f*, int*, int)’:
/var/tmp/portage/media-libs/opencv-3.4.1-r1/work/opencv-3.4.1/modules/calib3d/src/calibinit.cpp:424:5: internal compiler error: Segmentation fault
 int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
     ^~~~~~~~~~~~~~~~~~~~~~~
0x7f9931adba3f ???
        /var/tmp/portage/sys-libs/glibc-2.26-r7/work/glibc-2.26/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f9931ac6efb __libc_start_main
        ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
make[2]: *** [modules/calib3d/CMakeFiles/opencv_calib3d.dir/build.make:81: modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/calibinit.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3830: modules/calib3d/CMakeFiles/opencv_calib3d.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
Comment 1 Johannes Hirte 2018-06-01 18:57:56 UTC
emerge --info

Portage 2.3.40 (python 3.6.5-final-0, default/linux/amd64/17.1, gcc-8.1.0, glibc-2.26-r7, 4.17.0-rc7-00042-ga3415f60dce2 x86_64)
=================================================================
System uname: Linux-4.17.0-rc7-00042-ga3415f60dce2-x86_64-AMD_PRO_A10-8700B_R6,_10_Compute_Cores_4C+6G-with-gentoo-2.6
KiB Mem:    15887784 total,    849160 free
KiB Swap:    4194304 total,   4190296 free
Head commit of repository gentoo: 2c4789275b1d9fd4bfd631d48e93eaad9a3d41be

Head commit of repository kde: efb4a97086f2ba1a05c94d05c8f105cfa9de479d

Head commit of repository qt: 4bb9562cec825b4c0c5c621ec9f334a103e78308

sh bash 4.4_p19
ld GNU ld (Gentoo 2.30 p2) 2.30.0
distcc 3.2rc1 x86_64-pc-linux-gnu [disabled]
ccache version 3.3.4 [disabled]
app-shells/bash:          4.4_p19::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.26.2::gentoo
dev-lang/python:          2.7.14-r2::gentoo, 3.5.5-r1::gentoo, 3.6.5-r1::gentoo
dev-util/ccache:          3.3.4-r1::gentoo
dev-util/cmake:           3.11.2::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.30-r2::gentoo
sys-devel/gcc:            7.3.0-r3::gentoo, 8.1.0-r3::gentoo
sys-devel/gcc-config:     1.9.1::gentoo
sys-devel/libtool:        2.4.6-r5::gentoo
sys-devel/make:           4.2.1-r3::gentoo
sys-kernel/linux-headers: 4.16-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.26-r7::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: git://anongit.gentoo.org/repo/gentoo.git
    priority: -1000

kde
    location: /usr/local/portage/kde
    sync-type: git
    sync-uri: git://anongit.gentoo.org/proj/kde.git
    masters: gentoo
    priority: 50

local
    location: /usr/local/portage/local
    masters: gentoo
    priority: 50

qt
    location: /usr/local/portage/qt
    sync-type: git
    sync-uri: git://anongit.gentoo.org/proj/qt.git
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=bdver4 -msahf -mpopcnt -mlzcnt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=bdver4 -ftree-vectorize -fvect-cost-model -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.2/ext-active/ /etc/php/cgi-php7.2/ext-active/ /etc/php/cli-php7.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=bdver4 -msahf -mpopcnt -mlzcnt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=bdver4 -ftree-vectorize -fvect-cost-model -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --quiet-build=n"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync metadata-transfer multilib-strict news parallel-fetch preserve-libs sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="de en"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/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="X a52 aac aacplus acl alsa amd64 amr amrenc anacron berkdb bluetooth bzip2 cairo caps celt chm clang cleartype_hinting cli corefonts crypt cryptsetup cups cxx d3d9 dbus device-mapper djvu dri drm dvd ebook editorconfig efi egl eps epub evdev exif faac ffmpeg fftw flac fontconfig fortran gbm gdbm gif git glamor gmp gold gpg gphoto2 gpm graphviz harfbuzz iconv icu id3tag ipv6 ithreads jemalloc jpeg kipi lcms lensfun libatomic libcxx libcxxabi libffi libinput libkms libsamplerate libunwind lm_sensors lz4 lzma lzo mad matroska mjpeg mmap mng mobi modern-top modules mp3 mpeg mtp multilib mysql ncurses networkmanager nfs nls nptl ogg openal opencl opencv openexr opengl openmp openssl opus pam parted pcre pcre16 pdf png policykit postscript pulseaudio python qt5 raw readline s3tc schroedinger sdl sdl2 seccomp sift smp sndfile sox speex spice sqlite ssl subversion svg system-harfbuzz system-icu system-jpeg system-jsoncpp system-libvpx system-sqlite systemd taglib tcpd tesseract theora threads thumbnail tiff truetype udev unicode urandom usb usbredir user-session v4l vaapi vde vdpau vhosts virgl virt-network virtfs vorbis vpx vte vulkan wavpack wayland webp wmf x264 x265 xattr xcb xcomposite xkb xml xmp xpm xv xvid zlib zstd" 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="karbon plan sheets stage words" CAMERAS="canon ricoh ricoh_g3" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="avx avx2 f16c fma3 fma4 mmx mmxext popcnt sse sse2 sse3 ssse3 sse4_1 sse4_2 xop" CURL_SSL="openssl" 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" GRUB_PLATFORMS="efi-32 efi-64 pc" INPUT_DEVICES="evdev libinput synaptics" KERNEL="linux" L10N="de en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="AMDGPU BPF NVPTX X86" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby25" USERLAND="GNU" VIDEO_CARDS="amdgpu" 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, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Johannes Hirte 2018-06-01 19:00:49 UTC
Created attachment 534424 [details]
build.log
Comment 3 Johannes Hirte 2018-06-01 19:01:16 UTC
Created attachment 534426 [details]
build-abi_x86_64.amd64.log
Comment 4 Johannes Hirte 2018-06-01 19:05:49 UTC
same error with media-libs/opencv-3.3.0-r5
Comment 5 Johannes Hirte 2018-06-04 12:41:19 UTC
As the "during GIMPLE pass: vect" imply, omitting -ftree-vectorize -fvect-cost-model make it compile.
Comment 6 Johannes Hirte 2018-06-05 14:41:36 UTC
Core2 duo and skylake seems not to be affected. Wasn't able to reproduce it on those systems.
Comment 7 Johannes Hirte 2018-06-05 16:50:38 UTC
I just noticed this bug is assigned to Amy Liffey. It's a gcc-8 bug, not a opencv one.
Comment 8 Johannes Hirte 2018-08-01 04:23:20 UTC
segfault still occurs with gcc-8.2.0
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2018-08-05 00:09:26 UTC
Can you extract preprocessed file and needed gcc options to trigger the failure?
https://wiki.gentoo.org/wiki/Gcc-ICE-reporting-guide should help in that.
Comment 10 Johannes Hirte 2018-08-06 10:45:19 UTC
Created attachment 542530 [details]
reduced testcase

reduced testcase added

cflags, that trigger the ICE:
-O2 -march=bdver4 -ftree-vectorize

It's avx2-related. Adding -mno-avx2 works, -march=broadwell or -march=core2 -mavx2 fails.
Comment 11 Sergei Trofimovich (RETIRED) gentoo-dev 2018-08-06 20:24:10 UTC
(In reply to Johannes Hirte from comment #10)
> Created attachment 542530 [details]
> reduced testcase
> 
> reduced testcase added
> 
> cflags, that trigger the ICE:
> -O2 -march=bdver4 -ftree-vectorize
> 
> It's avx2-related. Adding -mno-avx2 works, -march=broadwell or -march=core2
> -mavx2 fails.

Thank you! Crashes here as well! I'll try git master and will forward your find upstream.

LANG=C g++ -O2 -march=bdver4 -ftree-vectorize -c a.c
during GIMPLE pass: vect
a.c: In function 'void fn1()':
a.c:34:6: internal compiler error: Segmentation fault
 void fn1() {
      ^~~
0xb59f3f crash_signal
        /usr/src/debug/sys-devel/gcc-8.1.0-r3/gcc-8.1.0/gcc/toplev.c:325
0x7f70a291289f ???
        /usr/src/debug/sys-libs/glibc-2.28/glibc-2.28/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xd5adfb first_readonly_imm_use
        /usr/src/debug/sys-devel/gcc-8.1.0-r3/gcc-8.1.0/gcc/ssa-iterators.h:352
0xd5adfb vect_transform_stmt(gimple*, gimple_stmt_iterator*, bool*, _slp_tree*, 
...
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2018-08-06 20:43:21 UTC
> I'll try git master and will forward your find upstream.

Crashes on today's git master as well. Reported upstream as:
    https://gcc.gnu.org/PR86871
Comment 13 Johannes Hirte 2018-12-18 21:42:43 UTC
Any chance to get the patch backported to gcc-8.2.0?
Comment 14 Larry the Git Cow gentoo-dev 2018-12-18 22:38:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=134dc72e3b4e140756f00b65688f084188f59d18

commit 134dc72e3b4e140756f00b65688f084188f59d18
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-12-18 22:37:25 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-12-18 22:37:25 +0000

    8.2.0: backport avx2 codegen SIGSEGV, bug #657060
    
    Fixes SIGSEGV when building media-libs/opencv-3.4.1-r1
    
    Reported-by: Johannes Hirte
    Bug: https://bugs.gentoo.org/657060
    Bug: https://gcc.gnu.org/PR86871
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 8.2.0/gentoo/115_all_avx2-SIGSEGV-PR86871.patch | 69 +++++++++++++++++++++++++
 8.2.0/gentoo/README.history                     |  1 +
 2 files changed, 70 insertions(+)
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2018-12-18 22:40:23 UTC
Yeah, makes sense. Queued for next gcc-8.2 patchset.

Meanwhile can you drop the patch to '/etc/portage/patches/sys-devel/gcc:8.2.0/' and verify patch works?
Comment 16 Johannes Hirte 2018-12-19 07:21:04 UTC
(In reply to Sergei Trofimovich from comment #15)
> Yeah, makes sense. Queued for next gcc-8.2 patchset.
> 
> Meanwhile can you drop the patch to
> '/etc/portage/patches/sys-devel/gcc:8.2.0/' and verify patch works?

Already tested it and works for me.
Comment 17 Sergei Trofimovich (RETIRED) gentoo-dev 2018-12-19 07:34:37 UTC
Thanks for the test and bug report! We'll cut new patchset in 1-2 weeks.
Comment 18 Larry the Git Cow gentoo-dev 2018-12-26 19:40:15 UTC
The bug has been referenced in the following commit(s):

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

commit d27b9469785e09efe5e808af0dfbf7eebdeaf627
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-12-26 19:37:14 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-12-26 19:39:59 +0000

    sys-devel/gcc: bump up to 1.7 patchset
    
    Two new patches:
    + 114_all_kr-decl-PR88214.patch: ICE on k&r declarations
    + 115_all_avx2-SIGSEGV-PR86871.patch: ICE in vectorizer
    
    Bug: https://bugs.gentoo.org/672032
    Bug: https://bugs.gentoo.org/657060
    Package-Manager: Portage-2.3.52, Repoman-2.3.12
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/gcc/Manifest            |  1 +
 sys-devel/gcc/gcc-8.2.0-r6.ebuild | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
Comment 19 Sergei Trofimovich (RETIRED) gentoo-dev 2018-12-26 19:58:39 UTC
Pushed as =sys-devel/gcc-8.2.0-r6.
Thanks for the report and reproducer!