#10549 closed defect (fixed)

Segfault when decoding aac

Reported by: Abbott Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: aac avcodec
Cc: Abbott, Sam James Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffplay test.mkv

ffmpeg version:

% ffmpeg -version
ffmpeg version N-111873-gfba4546175 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13 (Gentoo 13.2.0 p3)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-9999/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --strip=x86_64-pc-linux-gnu-strip --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-march=native -O2 -pipe -ggdb3' --disable-static --enable-avfilter --disable-stripping --disable-optimizations --disable-libcelt --enable-nonfree --disable-indev=oss --disable-indev=jack --disable-indev=sndio --disable-outdev=oss --disable-outdev=sndio --enable-version3 --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --enable-gnutls --disable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libxml2 --disable-lzma --enable-network --disable-opencl --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --enable-vaapi --disable-vdpau --enable-vulkan --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --enable-openal --enable-opengl --enable-libv4l2 --enable-libpulse --enable-libdrm --disable-libjack --enable-libopencore-amrwb --enable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --disable-libfdk-aac --disable-libopenjpeg --disable-libjxl --enable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --enable-libopus --disable-libvpl --disable-libilbc --disable-librtmp --enable-libssh --enable-libspeex --disable-libsrt --enable-librsvg --disable-ffnvcodec --enable-libvorbis --enable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --enable-chromaprint --disable-cuda-llvm --enable-libflite --disable-frei0r --disable-libvmaf --disable-libfribidi --disable-fontconfig --disable-ladspa --enable-lcms2 --enable-libass --disable-libplacebo --disable-libtesseract --disable-lv2 --enable-libfreetype --enable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-amf --disable-libvo-amrwbenc --disable-libkvazaar --disable-libaom --enable-libmp3lame --disable-libopenh264 --enable-librav1e --disable-libsnappy --disable-libsvtav1 --disable-libtheora --disable-libtwolame --enable-libwebp --enable-libx264 --disable-libx265 --disable-libxvid --disable-gnutls --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages
libavutil      58. 17.100 / 58. 17.100
libavcodec     60. 24.100 / 60. 24.100
libavformat    60. 11.100 / 60. 11.100
libavdevice    60.  2.101 / 60.  2.101
libavfilter     9. 11.100 /  9. 11.100
libswscale      7.  3.100 /  7.  3.100
libswresample   4. 11.100 /  4. 11.100
libpostproc    57.  2.100 / 57.  2.100

built on x86_64 Gentoo:

% uname -a
Linux aquarius 6.3.10-gentoo-dist #1 SMP PREEMPT_DYNAMIC Wed Jun 28 18:34:30 -00 2023 x86_64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz GenuineIntel GNU/Linux

Attachments (1)

ffplay_bt.log (19.0 KB ) - added by Abbott 15 months ago.
backtrace from ffplay when the segfault occurs

Download all attachments as: .zip

Change History (9)

by Abbott, 15 months ago

Attachment: ffplay_bt.log added

backtrace from ffplay when the segfault occurs

comment:1 by Abbott, 15 months ago

test.mkv was too big to upload (18.6M) and can instead be found here: test.mkv

comment:2 by Balling, 15 months ago

No issue here on windows.

comment:3 by kseniya-k, 13 months ago

A very similar issue is happening to me. ffprobe (which is used by ffplay and mpv) segfaults when opening anything with using the aac audio codec. Except, when I look at the stack trace, it segfaults at "src/libavcodec/aacdec_template.c:2227". I am also on Gentoo Linux. Yes, I have tried manually grabbing the source code for the recently released version 6.0.1 from github and compiling (with fairly similar configuration options), but that didn't help. Do you know what was the last version where this did not happen?

Glibc version: (Gentoo 2.37-r7 (patchset 10)) stable release version 2.37.

Last edited 13 months ago by kseniya-k (previous) (diff)

in reply to:  3 comment:4 by Abbott, 13 months ago

Replying to kseniya-k:

A very similar issue is happening to me. ffprobe (which is used by ffplay and mpv) segfaults when opening anything with using the aac audio codec. Except, when I look at the stack trace, it segfaults at "src/libavcodec/aacdec_template.c:2227". I am also on Gentoo Linux. Yes, I have tried manually grabbing the source code for the recently released version 6.0.1 from github and compiling (with fairly similar configuration options), but that didn't help. Do you know what was the last version where this did not happen?

Glibc version: (Gentoo 2.37-r7 (patchset 10)) stable release version 2.37.

The issue I was experiencing had to do with not setting my CPU_FLAGS_X86 correctly and one of the functions in libavcodec is using an instruction that I had not enabled (for me it was vmovdqa from avx). I had -avx in my ffmpeg USE, but for some reason avx is enabled anyway when it detects that my CPU can do it, even though the instruction is disabled in make.conf. To check and fix this, install app-portage/cpuid2cpuflags and populate CPU_FLAGS_X86 in make.conf with what you get from that program. Ensure your ffmpeg USE reflects what your CPU can do and then rebuild ffmpeg. Your ffmpeg and ffprobe should stop segfaulting after that.

I wanted to update the bug here for posterity, but because this is not a bug with ffmpeg, this bug can be closed.

Last edited 13 months ago by Abbott (previous) (diff)

comment:5 by Abbott, 13 months ago

Resolution: invalid
Status: newclosed

comment:6 by Sam James, 12 months ago

Cc: Sam James added
Resolution: invalid
Status: closedreopened

No, this isn't invalid, it's just an unusual configuration (and not really a necessary one, but still). BtbN and I ended up discussing it in #gcc as well.

The issue is that 16 byte alignment is assumed with --disable-avx but with some -march implying avx + the attributes used for 32, gcc assumes 32 elsewhere too.

(On the Gentoo side, we're going to likely always build the SIMD support and rely on runtime detection as BtbN advised, but still.)

comment:8 by Sam James, 10 months ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.