libavcodec crashs with the message "Bus error" when calling avcodec_encode_video2 . I am using libavcodec to encode video using AV_CODEC_ID_H264. After some calls of avcodec_encode_video2 the program crashs with error Bus error (imagem do núcleo gravada) Follow is the full log of my program: =============================================== [ota@Xbeaglebone /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ ./cameraserver xareu webcam 0 Versao da avutil 3546980 Versao da avcodec 3685476 Utiliando codec H264 [libx264 @ 0x29e22000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 0x29e22000] profile High, level 1.3 Conectado ao espelho em xareu OPEN Webcam configurada para: 320x240 at 25 fps Bus error (imagem do núcleo gravada) =============================================== This is my system: =============================================== [ota@Xbeaglebone /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ uname -a FreeBSD Xbeaglebone 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r292177M: Mon Dec 14 05:35:35 BRT 2015 ota@Xbeaglebone:/usr/obj/usr/src/sys/GENERIC i386 =============================================== ffmpeg is compiled with this options: =============================================== [ota@Xbeaglebone /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ pkg info ffmpeg-2.8.4,1 ffmpeg-2.8.4,1 Name : ffmpeg Version : 2.8.4,1 Installed on : Wed Jan 6 11:55:17 2016 BRT Origin : multimedia/ffmpeg Architecture : freebsd:11:x86:32 Prefix : /usr/local Categories : multimedia net audio ipv6 Licenses : LGPL21 and GPLv2 Maintainer : multimedia@FreeBSD.org WWW : http://ffmpeg.org/ Comment : Realtime audio/video encoder/converter and streaming server Options : AACPLUS : off ALSA : off AMR_NB : off AMR_WB : off ASS : off BS2B : off CACA : off CDIO : off CELT : off DC1394 : off DEBUG : off DOCS : off FAAC : off FDK_AAC : off FFSERVER : on FLITE : off FONTCONFIG : on FREETYPE : on FREI0R : on FRIBIDI : off GME : off GNUTLS : on GPL3 : off GSM : off ICONV : on ILBC : off JACK : off LADSPA : off LAME : off LIBBLURAY : off MMX : on MODPLUG : off NONFREE : off OPENAL : off OPENCL : off OPENCV : off OPENGL : off OPENH264 : off OPENJPEG : on OPENSSL : off OPTIMIZED_CFLAGS: off OPUS : off PULSEAUDIO : off QUVI : off RTCPU : on RTMP : off SCHROEDINGER : on SDL : off SMB : off SNAPPY : off SPEEX : off SSE : off SSH : off THEORA : on TWOLAME : off V4L : off VAAPI : off VDPAU : off VIDSTAB : off VORBIS : on VO_AACENC : off VO_AMRWBENC : off VPX : on WAVPACK : off WEBP : off X11GRAB : on X264 : on X265 : off XCB : off XVID : on XVIDEO : off ZMQ : off ZVBI : off Shared Libs required: libX11.so.6 libXext.so.6 libtheoraenc.so.1 libschroedinger-1.0.so.0 libfreetype.so.6 libgmp.so.10 libvorbisenc.so.2 libx264.so.144 libxvidcore.so.4 libvorbis.so.0 libvpx.so.2 libopenjpeg.so.2 libfontconfig.so.1 libgnutls.so.28 libtheoradec.so.1 libXfixes.so.3 Shared Libs provided: libavfilter.so.5 libavcodec.so.56 libavdevice.so.56 libavformat.so.56 libavresample.so.2 libswresample.so.1 libpostproc.so.53 libswscale.so.3 libavutil.so.54 Annotations : cpe : cpe:2.3:a:ffmpeg:ffmpeg:2.8.4:::::freebsd11:x86 Flat size : 35.0MiB Description : FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library. WWW: http://ffmpeg.org/ =============================================== My processor is a i7 3517U and I am running this machine inside a virtual box.
The same error is occurring with beaglebone black. =============================================== % ./cameraserver xareu webcam 0 Versao da avutil 3546980 Versao da avcodec 3685476 Utiliando codec H264 [libx264 @ 0x21e1f000] using cpu capabilities: ARMv6 NEON [libx264 @ 0x21e1f000] profile High, level 1.3 Conectado ao espelho em xareu OPEN v4l1_ioctl(fd,VIDIOCGPICT,&vp) OK v4l1_ioctl(fd,VIDIOCSPICT,&vp) OK v4l1_ioctl(fd,VIDIOCSWIN,&vw) OK Webcam configurada para: 320x240 at 25 fps av_init_packet(&pkt) OK Bus error (core dumped) =============================================== The system is a beaglebone black: =============================================== % uname -a FreeBSD beaglebone 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r292177M: Thu Dec 17 09:16:34 BRT 2015 ota@Xbeaglebone:/root/crochet-freebsd/work/obj/arm.armv6/usr/src/sys/BEAGLEBONE-DEBUG arm =============================================== ffmpeg is compiled with this options: =============================================== % pkg info ffmpeg-2.8.3_1,1 ffmpeg-2.8.3_1,1 Name : ffmpeg Version : 2.8.3_1,1 Installed on : Wed Dec 23 02:29:19 2015 UTC Origin : multimedia/ffmpeg Architecture : freebsd:11:armv6:32:el:eabi:softfp Prefix : /usr/local Categories : multimedia net audio ipv6 Licenses : LGPL21 and GPLv2 Maintainer : multimedia@FreeBSD.org WWW : http://ffmpeg.org/ Comment : Realtime audio/video encoder/converter and streaming server Options : AACPLUS : off ALSA : off AMR_NB : off AMR_WB : off ASS : off BS2B : off CACA : off CDIO : off CELT : off DC1394 : off DEBUG : off DOCS : off FAAC : off FDK_AAC : off FFSERVER : off FLITE : off FONTCONFIG : off FREETYPE : off FREI0R : off FRIBIDI : off GME : off GNUTLS : on GPL3 : off GSM : off ICONV : on ILBC : off JACK : off LADSPA : off LAME : off LIBBLURAY : off LIBV4L : on MODPLUG : off NEON : off NONFREE : on OPENAL : off OPENCL : off OPENCV : off OPENGL : off OPENH264 : off OPENJPEG : on OPENSSL : off OPTIMIZED_CFLAGS: on OPUS : off PULSEAUDIO : off QUVI : off RTCPU : on RTMP : off SCHROEDINGER : on SDL : off SMB : off SNAPPY : off SPEEX : off SSH : off THEORA : on TWOLAME : off VAAPI : off VDPAU : off VFP : off VIDSTAB : off VORBIS : on VO_AACENC : off VO_AMRWBENC : off VPX : on WAVPACK : off WEBP : off X11GRAB : off X264 : on X265 : on XCB : off XVID : on XVIDEO : off ZMQ : off ZVBI : off Shared Libs required: libgmp.so.10 Annotations : cpe : cpe:2.3:a:ffmpeg:ffmpeg:2.8.3:::::freebsd11:armv6:1 repo_type : binary repository : bbb Flat size : 33.0MiB Description : FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library. WWW: http://ffmpeg.org/
On i386 I have found that the problem is related with libx264. Using gdb: Program received signal SIGBUS, Bus error. 0x29671740 in x264_add8x8_idct_avx2.skip_prologue () from /usr/local/lib/libx264.so.144 (gdb) And this is the source code where the problem occurs: libavcodec/libx264.c:283 283 ===> if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0) 284 return AVERROR_EXTERNAL; And this is the asm code where the problem occurs: Dump of assembler code from 0x29671740 to 0x29671840: ===>0x29671740 <x264_add8x8_idct_avx2.skip_prologue+12488>: lds (bad),%edi 0x29671741 <x264_add8x8_idct_avx2.skip_prologue+12489>: stc 0x29671742 <x264_add8x8_idct_avx2.skip_prologue+12490>: outsl %ds:(%esi),(%dx) 0x29671743 <x264_add8x8_idct_avx2.skip_prologue+12491>: add $0xe,%al Someone can help me to fix it?
It looks like your x86 of ffmpeg is compiled without SSE. Is there any particular reason for this? Especially since x264 tries to use AVX2.
I was compiling with no SSE because the first time that I faced this error message was on a beaglebone black. So, I was trying to debug this error on a i386 on virtualbox. Because of this I dont enable SSE, but I will try with SSE enabled on amd64 and post here the result. Thanks a lot!
I did a rebuild in an i386 with SSE enabled. So I recompile my software also but the bug still there. The same code of my software works when I use OpenH264. [ota@Xbeaglebone /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ pkg info ffmpeg-2.8.4,1 ffmpeg-2.8.4,1 Name : ffmpeg Version : 2.8.4,1 Installed on : Mon Jan 18 08:25:53 2016 BRT Origin : multimedia/ffmpeg Architecture : freebsd:11:x86:32 Prefix : /usr/local Categories : multimedia net audio ipv6 Licenses : LGPL21 and GPLv2 Maintainer : multimedia@FreeBSD.org WWW : http://ffmpeg.org/ Comment : Realtime audio/video encoder/converter and streaming server Options : AACPLUS : off ALSA : off AMR_NB : off AMR_WB : off ASS : off BS2B : off CACA : off CDIO : off CELT : off DC1394 : off DEBUG : on DOCS : off FAAC : off FDK_AAC : off FFSERVER : on FLITE : off FONTCONFIG : on FREETYPE : on FREI0R : on FRIBIDI : off GME : off GNUTLS : on GPL3 : off GSM : off ICONV : on ILBC : off JACK : off LADSPA : off LAME : off LIBBLURAY : off MMX : on MODPLUG : off NONFREE : off OPENAL : off OPENCL : off OPENCV : off OPENGL : off OPENH264 : off OPENJPEG : on OPENSSL : off OPTIMIZED_CFLAGS: off OPUS : off PULSEAUDIO : off QUVI : off RTCPU : on RTMP : off SCHROEDINGER : on SDL : off SMB : off SNAPPY : off SPEEX : off SSE : on SSH : off THEORA : on TWOLAME : off V4L : on VAAPI : off VDPAU : off VIDSTAB : off VORBIS : on VO_AACENC : off VO_AMRWBENC : off VPX : on WAVPACK : off WEBP : off X11GRAB : on X264 : on X265 : off XCB : off XVID : on XVIDEO : off ZMQ : off ZVBI : off Shared Libs required: libX11.so.6 libv4l2.so.0 libXext.so.6 libtheoraenc.so.1 libschroedinger-1.0.so.0 libfreetype.so.6 libgmp.so.10 libvorbisenc.so.2 libx264.so.144 libxvidcore.so.4 libvorbis.so.0 libvpx.so.2 libopenjpeg.so.2 libfontconfig.so.1 libgnutls.so.28 libtheoradec.so.1 libXfixes.so.3 Shared Libs provided: libavfilter.so.5 libavcodec.so.56 libavdevice.so.56 libavformat.so.56 libavresample.so.2 libswresample.so.1 libpostproc.so.53 libswscale.so.3 libavutil.so.54 Annotations : cpe : cpe:2.3:a:ffmpeg:ffmpeg:2.8.4:::::freebsd11:x86 Flat size : 250MiB Description : FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library. ========================================================================== [ota@Xbeaglebone /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ ./cameraserver xareu webcam 0 Versao da avutil 3546980 Versao da avcodec 3685476 Utiliando codec H264 [libx264 @ 0x2a022000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 0x2a022000] profile High, level 1.3 Conectado ao espelho em xareu OPEN Webcam configurada para: 320x240 at 25 fps Bus error (imagem do núcleo gravada)
*** Bug 204354 has been marked as a duplicate of this bug. ***
(In reply to otacilio.neto from comment #5) Just a question: You said you were using a i7 3517U. If I am not mistaken, this CPU predates AVX2. Could you try (for testing) and rebuild x264 without ASM (or patch the tarball manually to turn avx2 off) ?
Hello This is the specs of my CPU. I'm running FreeBSD inside a virtualbox guest. FreeBSD clang version 3.7.1 (tags/RELEASE_371/final 255217) 20151225 VT(vga): resolution 640x480 CPU: Intel(R) Core(TM) i7-3517U CPU @ 1.90GHz (2394.61-MHz K8-class CPU) Origin="GenuineIntel" Id=0x306a9 Family=0x6 Model=0x3a Stepping=9 Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2> Features2=0xdc98220b<SSE3,PCLMULQDQ,MON,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,XSAVE,OSXSAVE,AVX,RDRAND,HV> AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM> AMD Features2=0x1<LAHF> TSC: P-state invariant Hypervisor: Origin = "VBoxVBoxVBox" real memory = 4901044224 (4674 MB) avail memory = 4106301440 (3916 MB) Event timer "LAPIC" quality 400 ACPI APIC Table: <VBOX VBOXAPIC>
I did a upgrade to ffmpeg 2.8.5,1 with libx264-0.144.2533_1 and now it works on AMD64. But on ARM the bus error persists. AMD64------------------------------------------------------------------------- [ota@nostromo /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ pkg info ffmpeg-2.8.5,1 ffmpeg-2.8.5,1 Name : ffmpeg Version : 2.8.5,1 Installed on : Sat Jan 23 21:20:51 2016 BRT Origin : multimedia/ffmpeg Architecture : freebsd:11:x86:64 Prefix : /usr/local Categories : multimedia net audio ipv6 Licenses : LGPL21 and GPLv2 Maintainer : multimedia@FreeBSD.org WWW : http://ffmpeg.org/ Comment : Realtime audio/video encoder/converter and streaming server Options : AACPLUS : off ALSA : off AMR_NB : off AMR_WB : off ASS : off BS2B : off CACA : off CDIO : off CELT : off DC1394 : off DEBUG : on DOCS : off FAAC : off FDK_AAC : off FFSERVER : on FLITE : off FONTCONFIG : on FREETYPE : on FREI0R : on FRIBIDI : off GME : off GNUTLS : on GPL3 : off GSM : off ICONV : on ILBC : off JACK : off LADSPA : off LAME : off LIBBLURAY : off MMX : on MODPLUG : off NONFREE : off OPENAL : off OPENCL : off OPENCV : off OPENGL : off OPENH264 : off OPENJPEG : on OPENSSL : off OPTIMIZED_CFLAGS: off OPUS : off PULSEAUDIO : off QUVI : off RTCPU : on RTMP : off SCHROEDINGER : on SDL : off SMB : off SNAPPY : off SPEEX : off SSE : on SSH : off THEORA : on TWOLAME : off V4L : on VAAPI : off VDPAU : off VIDSTAB : off VORBIS : on VO_AACENC : off VO_AMRWBENC : off VPX : on WAVPACK : off WEBP : off X11GRAB : on X264 : on X265 : off XCB : off XVID : on XVIDEO : off ZMQ : off ZVBI : off Shared Libs required: libX11.so.6 libv4l2.so.0 libXext.so.6 libtheoraenc.so.1 libschroedinger-1.0.so.0 libfreetype.so.6 libgmp.so.10 libvorbisenc.so.2 libx264.so.144 libxvidcore.so.4 libvorbis.so.0 libvpx.so.3 libopenjpeg.so.2 libfontconfig.so.1 libgnutls.so.28 libtheoradec.so.1 libXfixes.so.3 Shared Libs provided: libavfilter.so.5 libavcodec.so.56 libavdevice.so.56 libavformat.so.56 libavresample.so.2 libswresample.so.1 libpostproc.so.53 libswscale.so.3 libavutil.so.54 Annotations : cpe : cpe:2.3:a:ffmpeg:ffmpeg:2.8.5:::::freebsd11:x64 Flat size : 248MiB Description : FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library. WWW: http://ffmpeg.org/ [ota@nostromo /usr/home/ota/workspace/SOFTWARE_Espelho/ExemploWinCamServer]$ pkg info libx264-0.144.2533_1 libx264-0.144.2533_1 Name : libx264 Version : 0.144.2533_1 Installed on : Sun Jan 17 20:28:34 2016 BRT Origin : multimedia/libx264 Architecture : freebsd:11:x86:64 Prefix : /usr/local Categories : multimedia Licenses : GPLv2 Maintainer : koobs@FreeBSD.org WWW : http://www.videolan.org/x264.html Comment : H.264/MPEG-4 AVC Video Encoding (Library) Options : ASM : on DEBUG : off GCC : off HI10P : off PGO : off Shared Libs provided: libx264.so.144 Annotations : Flat size : 2.32MiB Description : x264 is a free library for encoding H.264/AVC (aka MPEG-4 Part 10) video streams. Encoder features * CAVLC/CABAC * Multi-references * Intra: all modes (4x4 and 16x16 with all predictions) * Inter P: all partitions (from 16x16 down to 4x4) * Inter B: partitions from 16x16 down to 8x8 (including SKIP/DIRECT) * Ratecontrol: constant quantizer, constant bitrate, or multipass ABR * Scene cut detection WWW: http://www.videolan.org/x264.html ARMV6 (beaglebone black)----------------------------------------------------- % pkg info | grep ffmpeg ffmpeg-2.8.5,1 Realtime audio/video encoder/converter and streaming server % pkg info ffmpeg-2.8.5,1 ffmpeg-2.8.5,1 Name : ffmpeg Version : 2.8.5,1 Installed on : Thu Jan 21 19:55:59 2016 UTC Origin : multimedia/ffmpeg Architecture : freebsd:11:armv6:32:el:eabi:softfp Prefix : /usr/local Categories : multimedia net audio ipv6 Licenses : LGPL21 and GPLv2 Maintainer : multimedia@FreeBSD.org WWW : http://ffmpeg.org/ Comment : Realtime audio/video encoder/converter and streaming server Options : AACPLUS : off ALSA : off AMR_NB : off AMR_WB : off ASS : off BS2B : off CACA : off CDIO : off CELT : off DC1394 : off DEBUG : on DOCS : off FAAC : off FDK_AAC : off FFSERVER : on FLITE : off FONTCONFIG : on FREETYPE : on FREI0R : on FRIBIDI : off GME : off GNUTLS : off GPL3 : off GSM : off ICONV : on ILBC : off JACK : off LADSPA : off LAME : off LIBBLURAY : off MODPLUG : off NEON : off NONFREE : on OPENAL : off OPENCL : off OPENCV : off OPENGL : off OPENH264 : off OPENJPEG : on OPENSSL : on OPTIMIZED_CFLAGS: off OPUS : off PULSEAUDIO : off QUVI : off RTCPU : on RTMP : off SCHROEDINGER : on SDL : off SMB : off SNAPPY : off SPEEX : off SSH : off THEORA : on TWOLAME : off V4L : on VAAPI : off VDPAU : off VFP : off VIDSTAB : off VORBIS : on VO_AACENC : off VO_AMRWBENC : off VPX : on WAVPACK : off WEBP : off X11GRAB : off X264 : on X265 : off XCB : off XVID : on XVIDEO : off ZMQ : off ZVBI : off Annotations : cpe : cpe:2.3:a:ffmpeg:ffmpeg:2.8.5:::::freebsd11:armv6 repo_type : binary repository : nostromo Flat size : 244MiB Description : FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library. WWW: http://ffmpeg.org/ % pkg info libx264-0.144.2533_1 libx264-0.144.2533_1 Name : libx264 Version : 0.144.2533_1 Installed on : Thu Jan 21 19:55:59 2016 UTC Origin : multimedia/libx264 Architecture : freebsd:11:armv6:32:el:eabi:softfp Prefix : /usr/local Categories : multimedia Licenses : GPLv2 Maintainer : koobs@FreeBSD.org WWW : http://www.videolan.org/x264.html Comment : H.264/MPEG-4 AVC Video Encoding (Library) Options : ASM : on DEBUG : off GCC : off HI10P : off PGO : off Annotations : repo_type : binary repository : nostromo Flat size : 1.70MiB Description : x264 is a free library for encoding H.264/AVC (aka MPEG-4 Part 10) video streams. Encoder features * CAVLC/CABAC * Multi-references * Intra: all modes (4x4 and 16x16 with all predictions) * Inter P: all partitions (from 16x16 down to 4x4) * Inter B: partitions from 16x16 down to 8x8 (including SKIP/DIRECT) * Ratecontrol: constant quantizer, constant bitrate, or multipass ABR * Scene cut detection WWW: http://www.videolan.org/x264.html
FWIW, I have a similar problem on i386 -- using both 2.8.6 and the latest master-branch from ffmpeg git-repo: https://trac.ffmpeg.org/ticket/5231 It crashes in a different function for me, though. The work-around I used was to add --disable-sse2 to configure args temporarily... As you can see from that ticket, they will not even talk to you, unless you reproduce the problem with the very latest code from their repo, however.
I can confirm this issue with mediatomb which uses ffmeg: FreeBSD bsd1home 10.3-RELEASE-p4 FreeBSD 10.3-RELEASE-p4 #0: Sat May 28 09:52:35 UTC 2016 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386 mediatomb and ffmpeg from ports. Crah with sigbus, error 10. GDB session with mediatomb: 2016-07-31 22:40:08 DEBUG: [../src/metadata/ffmpeg_handler.cc:277] fillMetadata(): Running ffmpeg handler on /mediatomb/Tudo.... Program received signal SIGBUS, Bus error. [Switching to Thread 2b405100 (LWP 100289/mediatomb)] 0x2935f442 in avpriv_vorbis_parse_frame_flags () from /usr/local/lib/libavcodec.so.56 Recompiled ffmpeg without SSE support. Mediatomb is running flawlessly now.
A work around to use H264 is compile with OpenH264.
In case compiler misoptimizes code on i386 check more recent version e.g., lang/gcc6 or lang/clang39. lang/clang* in particular lack base r242835, so passing -mstackrealign (as suggested in the upstream ticked) may not be required. (In reply to Mikhail T. from comment #10) > https://trac.ffmpeg.org/ticket/5231 Why do you insist on using the port's environment during build? From upstream POV any modification downstream even as simple as passing a non-default option is going to work against you. And as libavcodec.so gains dependencies from extra options those too have to be rebuilt with debugging symbols to get a useful stack trace. IIRC, building with debug symbols without losing optimizations is as simple as adding to make.conf STRIP = # empty CFLAGS += -g -fno-omit-frame-pointer # Vendors tend to force -fomit-frame-pointer OPTIONS_UNSET += OPTIMIZED_CFLAGS multimedia/ffmpeg may need to be patched as it relies on WITH_DEBUG horror from Mk/bsd.port.mk. Index: multimedia/ffmpeg/Makefile =================================================================== --- multimedia/ffmpeg/Makefile (revision 422449) +++ multimedia/ffmpeg/Makefile (working copy) @@ -122,7 +114,6 @@ DC1394_LIB_DEPENDS= libdc1394.so:multimedia/libdc1 DC1394_CONFIGURE_ENABLE= libdc1394 # debugging -DEBUG_CONFIGURE_ON= --disable-stripping DEBUG_CONFIGURE_OFF= --disable-debug # docs @@ -408,6 +394,7 @@ CONFIGURE_ARGS+=--prefix="${PREFIX}" \ --mandir="${PREFIX}/man" \ --datadir="${DATADIR}" \ --pkgconfigdir="${PREFIX}/libdata/pkgconfig" \ + ${STRIP:C/^[[:space:]]*$/--disable-stripping/} \ --enable-shared \ --enable-gpl \ --enable-postproc \
ports r422670 may fix some x264 crashes on i386 but probably only on very old (pre-SSE) hardware. ffmpeg doesn't have such a bug. However, defining CPUTYPE via make.conf(5) can still cause unwanted optimizations. --disable-sse (aka SSE=off in the port) also disables more recent instructions e.g., SSSE3, AVX. Can someone test the following switches on i386 arch individually? $ ./configure --help [...] --disable-amd3dnow disable 3DNow! optimizations --disable-amd3dnowext disable 3DNow! extended optimizations --disable-mmx disable MMX optimizations --disable-mmxext disable MMXEXT optimizations --disable-sse disable SSE optimizations --disable-sse2 disable SSE2 optimizations --disable-sse3 disable SSE3 optimizations --disable-ssse3 disable SSSE3 optimizations --disable-sse4 disable SSE4 optimizations --disable-sse42 disable SSE4.2 optimizations --disable-avx disable AVX optimizations --disable-xop disable XOP optimizations --disable-fma3 disable FMA3 optimizations --disable-fma4 disable FMA4 optimizations --disable-avx2 disable AVX2 optimizations --disable-aesni disable AESNI optimizations [...] --disable-inline-asm disable use of inline assembly --disable-fast-unaligned consider unaligned accesses slow [...]
Ping the reporters ... we do need some feedback here, otherwise we don't close the gap to a satisfying solution.
Solution? MMX and SSE are already disabled by default on i386 (check beefy* logs). dim@ posted a possible fix[1] on ports@ list which hasn't been confirmed yet. Otherwise, not much to do than expose more SIMD stuff as options to aid debugging. [1] https://lists.freebsd.org/pipermail/freebsd-ports/2016-September/104946.html
And if the fix works, I think, we should try to enable MMX/SSE by default on i386 as the optimizations are already gated by CPUID. Otherwise, SSE4 or AVX code would happily crash on amd64 as well.
My old computer died, so I dont have a place to test using a old CPU more. Today I will build using my i7 3517U and in next days using my beaglebone. After then I will report here.
Hi folks, I still use an old Pentium 4 as a small server at home. Willing to test, but I lost track has to be applied and tested. Please advise and I will test as requested.
Good news, I have tried the patch from here [1] on my old machine (Pentium 4, 2,4 GHz, i845 chipset): 1. SSE enabled, without patch: Mediatomb crashed immediately as it tried to read metadata from the MP4 file 2. SSE enabled, patch applied: works flawlessly. This patch does it's job. [1] https://lists.freebsd.org/pipermail/freebsd-ports/2016-September/104946.html
I too am happy to confirm, recompiling ffmpeg with the patch stops Firefox's plugin-container from crashing -- and taking the rest of the browser with it. The patch adds several flags to the compiler, it seems -- whereas the upstream's ticket suggests only the -mstackrealign Whether the patch is an "overkill" and/or a proper fix or merely a work-around, that pessimizes the binary, I do not know :(
FWIW, the upstream have officially blessed the -mstack-alignment=16, see: https://trac.ffmpeg.org/ticket/5231#comment:24
(In reply to Mikhail Teterin from comment #22) Миша, спасибо за поддержку!
@Assignee, if you're going to apply upstream fix, take care about forks/bundles as well. Don't disregard the issue just because no one has reported it against those ports yet. - multimedia/avidemux - multimedia/ffmpeg0 - multimedia/gstreamer-ffmpeg - multimedia/handbrake - multimedia/kodi - multimedia/libav - multimedia/mencoder - multimedia/mplayer - multimedia/mythtv - multimedia/mythtv-frontend - multimedia/plexhometheater Note, www/firefox et al. have bits of ffmpeg bundled in: avfft (WebAudio), ffvpx (VP9, FLAC), libavcodec API (H264, MP3). -mllvm -stack-alignment=16 isn't used during build, so maybe -mstack-alignment=16 isn't required, or just no one cared about Tier3 quirks. As many Firefox crashes on gecko@ lack symbols (infra issue) it's unknown if any are related to those bits until the fix here lands.
(In reply to Jan Beich (mail not working) from comment #24) For me, at least, firefox was the only canary suffocating from this problem. And, after applying the patch to ffmpeg, firefox stopped crashing. Obviously, this is yet another reminder of why we should strive to avoid code duplication -- even if an upstream vendor bundles their own copy of ffmpeg (or anything else), all efforts should be made for the already ported (and patched) library to be used instead.
(In reply to Jan Beich from comment #13) > lang/clang* in particular lack base r242835 Nevermind, I've mistook for GNU/kFreeBSD. If you're curious what led to that commit read this thread: https://lists.freebsd.org/pipermail/freebsd-current/2012-November/037563.html
A commit references this bug: Author: riggs Date: Sun Oct 9 12:19:32 UTC 2016 New revision: 423592 URL: https://svnweb.freebsd.org/changeset/ports/423592 Log: Fix runtime crashes on i386: enforce stack-alignment=16 PR: 205958 Submitted by: dim (patch via ports mailing list) Reported by: otacilio.neto@bsd.com.br MFH: 2016Q4 (ports-secteam fix blanket) Changes: head/multimedia/ffmpeg/Makefile head/multimedia/ffmpeg/files/patch-configure
A commit references this bug: Author: riggs Date: Sun Oct 9 12:30:37 UTC 2016 New revision: 423593 URL: https://svnweb.freebsd.org/changeset/ports/423593 Log: MFH: r423592 Fix runtime crashes on i386: enforce stack-alignment=16 PR: 205958 Submitted by: dim (patch via ports mailing list) Reported by: otacilio.neto@bsd.com.br Approved by: ports-secteam (fix blanket) Changes: _U branches/2016Q4/ branches/2016Q4/multimedia/ffmpeg/Makefile branches/2016Q4/multimedia/ffmpeg/files/patch-configure
So far, I have committed dim's patch which received positive feedback on i386. We need to verify whether a similar patch fixes the issue on arm. Could somebody with a beaglebone have a look?
(In reply to Jan Beich (mail not working) from comment #24) Right, we definitely need to have an eye on software that bundles (parts of) ffmpeg. However I tend to be reluctant to do pre-emptive commits in which I do not have the possibility to do a before/after check whether a problem is actually fixed.
(In reply to Thomas Zander from comment #29) Dear I will test in beaglebone, but I'm waiting the announce of 11-RELEASE because I need to rebuild my poudriere jail and a lot of ports. So I want do this one time because it takes long time and is resources eating.
(In reply to Thomas Zander from comment #29) > I have committed dim's patch which received positive feedback on i386. Any difference with upstream increases regression risk on updates, when the patch is removed, months after everyone have forgotten the context. However, despite mi@ giving positive feedback on upstream version, I'm getting opposite results: -mstackrealign is really needed. > We need to verify whether a similar patch fixes the issue on arm. If you've applied upstream fix, it'd force -mstack-alignment=16 on every platform, including arm. Whether that's correct on FreeBSD is a question for toolchain@ to ask. $ grep -r 'stackAlignment[[:space:]]*=' contrib/ contrib/llvm/lib/Target/X86/X86Subtarget.cpp: stackAlignment = StackAlignOverride; contrib/llvm/lib/Target/X86/X86Subtarget.cpp: stackAlignment = 16; contrib/llvm/lib/Target/X86/X86Subtarget.cpp: stackAlignment = 4; contrib/llvm/lib/Target/ARM/ARMSubtarget.cpp: stackAlignment = 8; contrib/llvm/lib/Target/ARM/ARMSubtarget.cpp: stackAlignment = 16; contrib/llvm/lib/Target/ARM/ARMSubtarget.h: unsigned stackAlignment = 4; According to http://fate.ffmpeg.org/ , darwin on non-x86 is green but tests are limited to "build only". Apparently, upstream undertests runtime despite landing d2af93ac1608 without x86_32 conditionals, risking crashes. (In reply to Thomas Zander from comment #30) > ... reluctant to do pre-emptive commits in which I do not have the > possibility to do a before/after check whether a problem is actually > fixed. Like possibility to chroot() inside i386 poudriere jail? The crash in question isn't limited to pre-SSE hardware but to SSE option enabled when building the port. Here's how to confirm ports r423592 on amd64: 1. Roll back to a commit before the fix 2. Rebuild the port with SSE=on or make sure --disable-sse doesn't show up 3. Decoding the sample attached to the upstream bug e.g., $ ffmpeg -i staples-short.mp4 -f yuv4mpegpipe -y /dev/null 4. With X11 apps make sure to allow libX11 et al. in jail to communicate with Xserver outside The results for other ports are likely to vary depending on which ffmpeg/libav version is bundled. Figuring out is left as a homework.
Oops, (3) step was a bit short on how to set up even non-X11 environment: $ poudriere bulk -h |& fgrep -i interactive -i -- Interactive mode. Enter jail for interactive testing and -I -- Advanced Interactive mode. Leaves jail running with ports $ poudriere bulk -ij 101i386 multimedia/ffmpeg
(In reply to Jan Beich (mail not working) from comment #32) > (In reply to Thomas Zander from comment #30) > > ... reluctant to do pre-emptive commits in which I do not have the > > possibility to do a before/after check whether a problem is actually > > fixed. > Like possibility to chroot() inside i386 poudriere jail? The crash in > question isn't limited to pre-SSE hardware but to SSE option enabled > when building the port. No, I was referring to situations in which nothing crashes to our knowledge. Whenever testing is easy/reproducible/possible, all is fine. But, for instance, several of the ports with parts of ffmpeg bundled you mentioned in comment #24 are not confirmed to exhibit the problem.
(In reply to Jan Beich (mail not working) from comment #32) > However, despite mi@ giving positive feedback on upstream version I'm sorry, I was not clear. Personally I only tested the patch first mentioned in Comment #16: https://lists.freebsd.org/pipermail/freebsd-ports/2016-September/104946.html That patch helped me and I advised upstream of same. Carl Eugene from the FFMpeg project then used an account I created for him on my computer to develop (what he believes to be) a proper fix: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac160872124b4066a77415eb06007c7326 If his change does not, in fact, fix our problem, we'll need to reopen the upstream ticket: https://trac.ffmpeg.org/ticket/5231
(In reply to Jan Beich (mail not working) from comment #32) > No, I was referring to situations in which nothing crashes to our knowledge. avconv from multimedia/libav does crash, ENOTIME to test the rest. (In reply to Mikhail Teterin from comment #35) > If his change does not, in fact, fix our problem, we'll need to reopen the upstream ticket: Don't trust my Q/A, confirm yourself. The burden of ensuring the fix is adequate is on either users who are affected or the port maintainer. As upstream is very conservative about backporting fixes to release branches the issue here may not resurface until bug 207547 lands replacing dim's fix with upstream version (due to patch conflict).
I did a svnup and rebuild ffmpeg on two machines using defaults options from ports and the crash is gone when using Firefox and when encoding also. The processors used are these: Machine One (my old computer come back) CPU: Intel(R) Core(TM)2 CPU T5300 @ 1.73GHz (1729.03-MHz K8-class CPU) Origin="GenuineIntel" Id=0x6f2 Family=0x6 Model=0xf Stepping=2 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0xe39d<SSE3,DTES64,MON,DS_CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM> AMD Features=0x20100800<SYSCALL,NX,LM> AMD Features2=0x1<LAHF> TSC: P-state invariant, performance statistics Machine Two CPU: Intel(R) Core(TM) i7-3517U CPU @ 1.90GHz (2394.62-MHz K8-class CPU) Origin="GenuineIntel" Id=0x306a9 Family=0x6 Model=0x3a Stepping=9 Features=0x1783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2,HTT> Features2=0xdc982203<SSE3,PCLMULQDQ,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,XSAVE,OSXSAVE,AVX,RDRAND,HV> AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM> AMD Features2=0x1<LAHF> TSC: P-state invariant
Closed. Don't mix separate issues in a single bug. This one was predominantly i386-specific. (In reply to otacilio.neto from comment #1) > % ./cameraserver xareu webcam 0 > Versao da avutil 3546980 > Versao da avcodec 3685476 > Utiliando codec H264 > [libx264 @ 0x21e1f000] using cpu capabilities: ARMv6 NEON > [libx264 @ 0x21e1f000] profile High, level 1.3 > Conectado ao espelho em xareu OPEN > v4l1_ioctl(fd,VIDIOCGPICT,&vp) OK > v4l1_ioctl(fd,VIDIOCSPICT,&vp) OK > v4l1_ioctl(fd,VIDIOCSWIN,&vw) OK > Webcam configurada para: 320x240 at 25 fps > av_init_packet(&pkt) OK > Bus error (core dumped) BeagleBone Black has Cortex-A8 which should support NEON. Can you get a stacktrace from a build with debugging symbols? Open a new bug and post it there. (In reply to otacilio.neto from comment #9) > Architecture : freebsd:11:armv6:32:el:eabi:softfp FreeBSD 11.0 (per base r300119) switched armv6 to hardfp by default. Any other armv6 configuration is going to receive lackluster support in ports/ (if at all).
A commit references this bug: Author: jbeich Date: Wed Nov 9 08:48:09 UTC 2016 New revision: 425781 URL: https://svnweb.freebsd.org/changeset/ports/425781 Log: multimedia/libav: fix h264 decoder crash on 11.0+ i386 -mstackrealign isn't required (yet?) unlike multimedia/ffmpeg. PR: 205958 Obtained from: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac1608 Approved by: portmgr blanket Changes: head/multimedia/libav/Makefile head/multimedia/libav/files/patch-configure
A commit references this bug: Author: jbeich Date: Wed Nov 9 08:48:22 UTC 2016 New revision: 425782 URL: https://svnweb.freebsd.org/changeset/ports/425782 Log: multimedia/ffmpeg0: fix h264 decoder crash on 11.0+ i386 -mstackrealign isn't required yet unlike multimedia/ffmpeg. PR: 205958 Obtained from: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac1608 Approved by: portmgr blanket Changes: head/multimedia/ffmpeg0/Makefile head/multimedia/ffmpeg0/files/patch-configure
A commit references this bug: Author: jbeich Date: Wed Nov 9 08:51:13 UTC 2016 New revision: 425783 URL: https://svnweb.freebsd.org/changeset/ports/425783 Log: MFH: r425781 multimedia/libav: fix h264 decoder crash on 11.0+ i386 -mstackrealign isn't required (yet?) unlike multimedia/ffmpeg. PR: 205958 Obtained from: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac1608 Approved by: portmgr blanket Approved by: ports-secteam blanket Changes: _U branches/2016Q4/ branches/2016Q4/multimedia/libav/Makefile branches/2016Q4/multimedia/libav/files/patch-configure
A commit references this bug: Author: jbeich Date: Wed Nov 9 08:54:15 UTC 2016 New revision: 425784 URL: https://svnweb.freebsd.org/changeset/ports/425784 Log: MFH: r425782 multimedia/ffmpeg0: fix h264 decoder crash on 11.0+ i386 -mstackrealign isn't required yet unlike multimedia/ffmpeg. PR: 205958 Obtained from: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac1608 Approved by: portmgr blanket Approved by: ports-secteam blanket Changes: _U branches/2016Q4/ branches/2016Q4/multimedia/ffmpeg0/Makefile branches/2016Q4/multimedia/ffmpeg0/files/patch-configure
multimedia/mplayer hoarded the fix for the issue here since ports r375775. An example why bundlers are bad citizens.
A commit references this bug: Author: jbeich Date: Wed Nov 9 09:53:11 UTC 2016 New revision: 425786 URL: https://svnweb.freebsd.org/changeset/ports/425786 Log: multimedia/kodi: fix h264 decoder crash on 11.0+ i386 -mstackrealign isn't required (yet?) unlike multimedia/ffmpeg. PR: 205958 Obtained from: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac1608 Approved by: portmgr blanket Changes: head/multimedia/kodi/Makefile head/multimedia/kodi/files/patch-tools_depends_target_ffmpeg_FFmpeg-2.8.6-Jarvis-16.0_configure
A commit references this bug: Author: jbeich Date: Wed Nov 9 09:55:19 UTC 2016 New revision: 425787 URL: https://svnweb.freebsd.org/changeset/ports/425787 Log: MFH: r425786 multimedia/kodi: fix h264 decoder crash on 11.0+ i386 -mstackrealign isn't required (yet?) unlike multimedia/ffmpeg. PR: 205958 Obtained from: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=d2af93ac1608 Approved by: portmgr blanket Approved by: ports-secteam blanket Changes: _U branches/2016Q4/ branches/2016Q4/multimedia/kodi/Makefile branches/2016Q4/multimedia/kodi/files/patch-tools_depends_target_ffmpeg_FFmpeg-2.8.6-Jarvis-16.0_configure
NetBSD bumped[1] into the same issue. IIUC, callers need to be fixed to avoid pessimization from using -mstackrealign. [1] https://gnats.netbsd.org/47132 [1] https://gnats.netbsd.org/51122