Bug 199715

Summary: graphics/opencv-core crashes ffmpeg
Product: Ports & Packages Reporter: Randy Westlund <rwestlun>
Component: Individual Port(s)Assignee: Jason E. Hale <jhale>
Status: Closed FIXED    
Severity: Affects Only Me CC: jhale, riggs, sasamotikomi
Priority: ---    
Version: Latest   
Hardware: i386   
OS: Any   

Description Randy Westlund 2015-04-26 18:22:10 UTC
graphics/opencv-core-2.4.9_2
multimedia/ffmpeg-2.3.6_2,1

When I invoke ffmpeg it immediately crashes regardless of command line options.  I ran 'make WITH_DEBUG=true' and found this:


root@alixbuild:/usr/ports/multimedia/ffmpeg/work/ffmpeg-2.3.6 # gdb -q ffmpeg                                                                                                                   
(no debugging symbols found)...(gdb) r
Starting program: /usr/ports/multimedia/ffmpeg/work/ffmpeg-2.3.6/ffmpeg 
(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...(no debugging symbols found)...[New LWP 100121]
(no debugging symbols found)...(no debugging symbols found)...[New Thread 2b003080 (LWP 100121/ffmpeg)]

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 2b003080 (LWP 100121/ffmpeg)]
0x298fe04c in cv::initInterTab1D (method=-1077949476, tab=0xbfbfcb64, tabsz=671658676) at /usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/imgproc/src/imgwarp.cpp:189
189     {
Current language:  auto; currently c++
(gdb) bt
#0  0x298fe04c in cv::initInterTab1D (method=-1077949476, tab=0xbfbfcb64, tabsz=671658676) at /usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/imgproc/src/imgwarp.cpp:189
#1  0x298c4f26 in cv::initInterTab2D (method=1, fixpt=false) at /usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/imgproc/src/imgwarp.cpp:230
#2  0x298a111c in cv::initAllInterTab2D () at /usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/imgproc/src/imgwarp.cpp:290
#3  0x298a10c8 in __cxx_global_var_init1 () at /usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/imgproc/src/imgwarp.cpp:298
#4  0x298fee70 in global constructors keyed to a () at /usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/imgproc/src/imgwarp.cpp:134
#5  0x29af5192 in __do_global_ctors_aux () from /usr/local/lib/libopencv_imgproc.so.2
#6  0x29829401 in _init () from /usr/local/lib/libopencv_imgproc.so.2
#7  0x00000000 in ?? ()
(gdb)


root@alixbuild:/usr/ports/multimedia/ffmpeg # uname -a
FreeBSD alixbuild.lan 10.1-RELEASE-p9 FreeBSD 10.1-RELEASE-p9 #0: Tue Apr  7 01:07:33 UTC 2015     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

I'm on an AMD Geode processor on an ALIX 2D13 board.
Comment 1 sasamotikomi 2015-05-16 01:42:18 UTC
(In reply to Randy Westlund from comment #0)
I have same problem 
$ ffmpeg
Illegal instruction (core dumped)
#0  0x295c5fd5 in cvRegisterModule () from /usr/local/lib/libopencv_core.so.2
[New Thread 2ac03080 (LWP 100778/ffmpeg)]
(gdb) bt full
#0  0x295c5fd5 in cvRegisterModule () from /usr/local/lib/libopencv_core.so.2
No symbol table info available.
#1  0x295c7276 in std::__1::vector<cv::TLSDataContainer*, std::__1::allocator<cv::TLSDataContainer*> >::__push_back_slow_path<cv::TLSDataContainer* const> ()
   from /usr/local/lib/libopencv_core.so.2
No symbol table info available.
#2  0x295c7572 in std::__1::vector<cv::TLSDataContainer*, std::__1::allocator<cv::TLSDataContainer*> >::__push_back_slow_path<cv::TLSDataContainer* const> ()
   from /usr/local/lib/libopencv_core.so.2
No symbol table info available.
#3  0x00000000 in ?? ()
No symbol table info available.

I think it's incorrect flag:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200234
Comment 2 Thomas Zander freebsd_committer 2015-06-14 09:41:49 UTC
This is a serious problem for people with pre-SSE processors. I could imagine there are quite a few systems out there still running on low power i386 Geodes or Atoms that cause issues here.

Jason, is this on your radar? TIA
Comment 3 commit-hook freebsd_committer 2015-06-14 15:28:11 UTC
A commit references this bug:

Author: jhale
Date: Sun Jun 14 15:28:04 UTC 2015
New revision: 389642
URL: https://svnweb.freebsd.org/changeset/ports/389642

Log:
  - Add SIMD option to specifically disable CPU optimizations and prevent crashes
    with ffmpeg on processors that do not support SSE instructions.  OFF by
    default for package building, ON with autodetect for ports to keep with
    POLA. [1][2]
  - Bump PORTREVISION on all opencv ports

  PR:		199715 [1], 200234 [2]
  Submitted by:	Randy Westlund <rwestlun@gmail.com> [1], sasamotikomi@gmail.com [2]

Changes:
  head/graphics/opencv/Makefile
  head/graphics/opencv-core/Makefile
  head/graphics/opencv-java/Makefile
  head/graphics/py-opencv/Makefile
Comment 4 Jason E. Hale freebsd_committer 2015-06-14 15:31:50 UTC
Should be fixed now in r389642.  Can you confirm that it works now with the SIMD option disabled?  (It should work with it enabled too as I have added some instruction set detection logic as well, but just in case.)
Comment 5 sasamotikomi 2015-06-15 03:33:43 UTC
(In reply to Jason E. Hale from comment #4)
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200234#c2
SSE2/3 issue is fixed so crash is gone but still triple match, doubled -O, which one is used if both O0 and O2 and match=i686,athlon-xp? also doubled -fno-strict-aliasing, -pipe etc.
Comment 6 Randy Westlund 2015-06-18 17:25:16 UTC
(In reply to Jason E. Hale from comment #4)

I can confirm that building opencv-core with SIMD disabled solves my problems.  I can run ffmpeg with OPENCV enabled now.
Comment 7 Randy Westlund 2015-08-17 18:06:06 UTC
After building opencv-core-2.4.9_3, I also see doubled options.  CFLAGS and CXXFLAGS overlap.


--MAKE_ENV--
XDG_DATA_HOME=/wrkdirs/usr/ports/graphics/opencv-core/work  XDG_CONFIG_HOME=/wrkdirs/usr/ports/graphics/opencv-core/work  HOME=/wrkdirs/usr/ports/graphics/opencv-core/work TMPDIR="/tmp" NO_PIE=yes SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local  LOCALBASE=/usr/local  LIBDIR="/usr/lib"  CC="cc" CFLAGS="-O -pipe  -fno-strict-aliasing"  CPP="cpp" CPPFLAGS=""  LDFLAGS="" LIBS=""  CXX="c++" CXXFLAGS="-O -pipe -fno-strict-aliasing "  MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install  -s -m 555"  BSD_INSTALL_LIB="install  -s -m 444"  BSD_INSTALL_SCRIPT="install  -m 555"  BSD_INSTALL_DATA="install  -m 0644"  BSD_INSTALL_MAN="install  -m 444"
--End MAKE_ENV--


Leading to lines like this, with some options specified twice:

[  5%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.o
cd /wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/core && /usr/bin/c++   -DCVAPI_EXPORTS -O -pipe -fno-strict-aliasing   -fsigned-char -W -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -O -pipe -fno-strict-aliasing  -DNDEBUG -fPIC -I/wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/dynamicuda/include -I/wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/core -I/wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/core/src -I/wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/core/include -I/wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9 -isystem /usr/local/include/eigen3 -o CMakeFiles/opencv_core.dir/src/parallel.cpp.o -c /wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/modules/core/src/parallel.cpp
/usr/local/bin/cmake -E cmake_progress_report /wrkdirs/usr/ports/graphics/opencv-core/work/opencv-2.4.9/CMakeFiles 5


I can't find where these are defined.
Comment 8 Jason E. Hale freebsd_committer 2016-09-19 22:55:38 UTC
Return to pool.
Comment 9 Jan Beich freebsd_committer 2016-11-14 16:02:23 UTC
Probably because vendor makefile appends CXXFLAGS to CFLAGS. Anyway, file a new bug with more details as it's unrelated to crashes.
Comment 10 Jan Beich freebsd_committer 2016-11-14 16:03:22 UTC
Assign to committer who landed the fix.