Summary: | ffmpeg runtime segfault with lto | ||
---|---|---|---|
Product: | gcc | Reporter: | Manuel Lauss <manuel.lauss> |
Component: | lto | Assignee: | Martin Liška <marxin> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | cehoyos |
Priority: | P3 | ||
Version: | 8.0.1 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2018-03-31 00:00:00 |
Description
Manuel Lauss
2018-03-30 18:31:41 UTC
Hi Manual. Can you please reduce a bit the configure options. The package requires many libraries as dependency. How do you invoke ffmpeg to expose the crash? This is the most minimal ffmpeg config that can trigger the segfault. The interesting switch is "--enabled-hardcoded-tables". I use the "mpv" Player with a standard mp4 video file to trigger it (https://github.com/mpv-player/mpv/archive/v0.27.2.zip) configure --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-3.4.2-r1/html --mandir=/usr/share/man --enable-share d --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags=-O3 -ggdb -march=znver1 -mtune=znver1 -flto=16 -fno-fat-lto-objects -pipe --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-encoders --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable -indev=jack --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sdl --disable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --disable-gnutls --disable-gmp --enable-gpl --enable-hardco ded-tables --disable-iconv --disable-lzma --disable-network --disable-opencl --disable-openssl --disable-postproc --disable-libsmbclient --disable-ffplay --disable-sdl2 --disable-vaapi --disable-vdpau --disable-x lib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --disable-opengl --disable-libv4l2 - -disable-libpulse --disable-libdrm --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libcelt --disable-libgme --disable-libgsm --disa ble-mmal --disable-libmodplug --disable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --disable-librsvg --disable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit -- disable-libbs2b --disable-chromaprint --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --disable-libfreetype --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disa ble-mipsfpu --disable-altivec --disable-amd3dnow --disable-amd3dnowext --disable-fma4 --disable-xop --cpu=znver1 --enable-lto --disable-doc --disable-htmlpages --enable-manpages (In reply to Manuel Lauss from comment #2) > This is the most minimal ffmpeg config that can trigger the segfault. The > interesting switch is "--enabled-hardcoded-tables". I use the "mpv" Player > with a standard mp4 video file to trigger it > (https://github.com/mpv-player/mpv/archive/v0.27.2.zip) Good. so we have minimal set of options for ffmpeg. Now please explain me how to build the MPV tool? Is it really needed? Can't one trigger that directly with ffmepg? Please upload somewhere the mp4 file so that I can reproduce it. (In reply to Martin Liška from comment #3) > (In reply to Manuel Lauss from comment #2) > > This is the most minimal ffmpeg config that can trigger the segfault. The > > interesting switch is "--enabled-hardcoded-tables". I use the "mpv" Player > > with a standard mp4 video file to trigger it > > (https://github.com/mpv-player/mpv/archive/v0.27.2.zip) > > Good. so we have minimal set of options for ffmpeg. Now please explain me > how to build the MPV tool? Is it really needed? Can't one trigger that > directly with ffmepg? Please upload somewhere the mp4 file so that I can > reproduce it. The segfault happens during initialization of ffmpeg when mpv player starts. I can also trigger it with firefox on e.g. youtube: it crashes the tab. ad mpv: unpack, configure with the following line (you need python3): CCFLAGS="-O3 -march=znver1 -mtune=znver1 -flto=16 -fno-fat-lto-objects -pipe" LINKFLAGS="-O3 -march=znver1 -mtune=znver1 -flto=16 -fno-fat-lto-objects -pipe -Wl,--no-as-needed" ./waf --prefix=/usr --libdir=/usr/lib64 --confdir=/etc/mpv --docdir=/usr/share/doc/mpv-0.27.2 --htmldir=/usr/share/doc/mpv-0.27.2/html --enable-libmpv-shared --disable-libmpv-static --disable-static-build --disable-optimize --disable-debug-build --enable-html-build --disable-pdf-build --enable-cplugins --disable-zsh-comp --disable-test --disable-android --enable-iconv --disable-libsmbclient --enable-lua --lua=luajit --disable-javascript --enable-x11 --disable-build-date configure ./waf build (In reply to Manuel Lauss from comment #4) > (In reply to Martin Liška from comment #3) > > (In reply to Manuel Lauss from comment #2) > > > This is the most minimal ffmpeg config that can trigger the segfault. The > > > interesting switch is "--enabled-hardcoded-tables". I use the "mpv" Player > > > with a standard mp4 video file to trigger it > > > (https://github.com/mpv-player/mpv/archive/v0.27.2.zip) > > > > Good. so we have minimal set of options for ffmpeg. Now please explain me > > how to build the MPV tool? Is it really needed? Can't one trigger that > > directly with ffmepg? Please upload somewhere the mp4 file so that I can > > reproduce it. > > The segfault happens during initialization of ffmpeg when mpv player starts. > I can also trigger it with firefox on e.g. youtube: it crashes the tab. Ok, so please download following sample video: http://techslides.com/demos/sample-videos/small.mp4 And try to run ffmpeg to print info: ./ffmpeg -i small.mp4 Does it also segfault? > > > ad mpv: unpack, configure with the following line (you need python3): > CCFLAGS="-O3 -march=znver1 -mtune=znver1 -flto=16 -fno-fat-lto-objects > -pipe" LINKFLAGS="-O3 -march=znver1 -mtune=znver1 -flto=16 > -fno-fat-lto-objects -pipe -Wl,--no-as-needed" ./waf --prefix=/usr > --libdir=/usr/lib64 --confdir=/etc/mpv --docdir=/usr/share/doc/mpv-0.27.2 > --htmldir=/usr/share/doc/mpv-0.27.2/html --enable-libmpv-shared > --disable-libmpv-static --disable-static-build --disable-optimize > --disable-debug-build --enable-html-build --disable-pdf-build > --enable-cplugins --disable-zsh-comp --disable-test --disable-android > --enable-iconv --disable-libsmbclient --enable-lua --lua=luajit > --disable-javascript --enable-x11 --disable-build-date configure > > ./waf build How the player knows where to find the built ffmpeg libraries? (In reply to Martin Liška from comment #5) > (In reply to Manuel Lauss from comment #4) > > (In reply to Martin Liška from comment #3) > > > (In reply to Manuel Lauss from comment #2) > > > > This is the most minimal ffmpeg config that can trigger the segfault. The > > > > interesting switch is "--enabled-hardcoded-tables". I use the "mpv" Player > > > > with a standard mp4 video file to trigger it > > > > (https://github.com/mpv-player/mpv/archive/v0.27.2.zip) > > > > > > Good. so we have minimal set of options for ffmpeg. Now please explain me > > > how to build the MPV tool? Is it really needed? Can't one trigger that > > > directly with ffmepg? Please upload somewhere the mp4 file so that I can > > > reproduce it. > > > > The segfault happens during initialization of ffmpeg when mpv player starts. > > I can also trigger it with firefox on e.g. youtube: it crashes the tab. > > Ok, so please download following sample video: > http://techslides.com/demos/sample-videos/small.mp4 > > And try to run ffmpeg to print info: > ./ffmpeg -i small.mp4 > > Does it also segfault? Yes, same backtrace, same fault location. (In reply to Manuel Lauss from comment #6) > (In reply to Martin Liška from comment #5) > > (In reply to Manuel Lauss from comment #4) > > > (In reply to Martin Liška from comment #3) > > > > (In reply to Manuel Lauss from comment #2) > > > > > This is the most minimal ffmpeg config that can trigger the segfault. The > > > > > interesting switch is "--enabled-hardcoded-tables". I use the "mpv" Player > > > > > with a standard mp4 video file to trigger it > > > > > (https://github.com/mpv-player/mpv/archive/v0.27.2.zip) > > > > > > > > Good. so we have minimal set of options for ffmpeg. Now please explain me > > > > how to build the MPV tool? Is it really needed? Can't one trigger that > > > > directly with ffmepg? Please upload somewhere the mp4 file so that I can > > > > reproduce it. > > > > > > The segfault happens during initialization of ffmpeg when mpv player starts. > > > I can also trigger it with firefox on e.g. youtube: it crashes the tab. > > > > Ok, so please download following sample video: > > http://techslides.com/demos/sample-videos/small.mp4 > > > > And try to run ffmpeg to print info: > > ./ffmpeg -i small.mp4 > > > > Does it also segfault? > > Yes, same backtrace, same fault location. Hm, I put __builtin_abort to: static av_cold void aac_static_table_init(void) function. And it's unfortunately called. Probably because: $ ./ffmpeg -i small.mp4 test.mp3 ... Decoder (codec aac) not found for input stream #0:1 Are you sure the configure options enable the codec (AAC)? Stupid mistake from me. Now I can reproduce that: LD_LIBRARY_PATH=./libavcodec/ gdb --args ./ffmpeg -i small.mp4 So it's really caused by --enable-hardcoded-tables. With that you have in sinewin.c pre-processed source file: extern const INTFLOAT __attribute__ ((aligned (32))) ff_sine_960[960]; As you can se, it's const (a.k.a. READONLY). Thus doing a write to it in ff_sine_window_init causes a segfault. Thus closing as invalid. Built with gcc-7.3.0 and LTO it works fine; is this a bug in 7.3.0 instead then? It was changed on trunk in: commit 371072bf395be11f36ef31bb3cfec06bbfc58597 Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri Sep 1 16:26:00 2017 +0000 * varasm.c (bss_initializer_p): Do not put constants into .bss (categorize_decl_for_section): Handle bss_initializer_p returning false when DECL_INITIAL is NULL. * gcc.target/i386/const-in-bss.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251602 138bc75d-0d04-0410-961f-82ee72b054a4 Note the using an undefined behavior gives optimizer opportunity to optimize to any way. In this case GCC 7 generated working and GCC 8 not working code in case of ffmpeg. Should be fixed: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=10f46815 https://trac.ffmpeg.org/ticket/7491 I wonder a little how the FFmpeg developers were supposed to find out about this bug... (In reply to Carl Eugen Hoyos from comment #12) > Should be fixed: > http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=10f46815 > https://trac.ffmpeg.org/ticket/7491 > > I wonder a little how the FFmpeg developers were supposed to find out about > this bug... Good, thanks for mainline fix! |