Opened 13 months ago

Closed 13 months ago

Last modified 13 months ago

#5920 closed defect (invalid)

static build FFmpeg segfault when VA-API hardware encoding

Reported by: warp Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: vaapi
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

static build ffmpeg segmentation faults when using VA-API hardware encoding.

How to reproduce:

build ffmpeg statically as below on Ubuntu 16.04
(to build static binary with vaapi support, I have to set "--extra-libs" value. Is this a know issue?)

apt update
apt upgrade -y
apt install -y \
 build-essential \
 git \
 libdrm-dev
 libva-dev
 nasm \
 pkg-config \
 yasm

git pull https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg

./configure \
 --prefix=/usr/local \
 --enable-pic \
 --enable-gpl \
 --enable-version3 \
 --enable-nonfree \
 --enable-static \
 --disable-shared \
 --disable-ffplay \
 --disable-doc \
 --extra-cflags="--static" \
 --extra-libs="-static -lva -ldl -ldrm -lm" \
 --enable-debug

 make

then,

# ./ffmpeg_g -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i /tmp/original.ts -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi -an /tmp/encoded.mp4
ffmpeg version n3.1.5 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
  configuration: --prefix=/usr/local --enable-pic --enable-gpl --enable-version3 --enable-nonfree --enable-static --disable-shared --disable-ffplay --disable-doc --extra-cflags=--static --extra-libs='-static -lva -ldl -ldrm -lm' --enable-debug
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
Segmentation fault (core dumped)

gdb output is http://pastebin.com/tpmAgJye
valgrind output is http://pastebin.com/3sLVB8m5

Change History (2)

comment:1 Changed 13 months ago by jkqxz

  • Resolution set to invalid
  • Status changed from new to closed

This is nothing to do with ffmpeg: libva cannot be linked into a static binary because it requires the dynamic linker to do driver loading.

Try building any of the libva test programs such as vainfo statically and you will find exactly the same problem:

$ file vainfo
vainfo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=41fb267b358b93b746803212bf305b6d6eca07f2, not stripped
$ gdb --args ./vainfo 
GNU gdb (Debian 7.11.1-2) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vainfo...done.
(gdb) r
Starting program: /home/mrt/video/libva/static/test/vainfo/vainfo 
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff79cffd0 in __pthread_initialize_minimal_internal () at nptl-init.c:471
#2  0x00007ffff79cf5b9 in _init () at ../sysdeps/x86_64/crti.S:72
#3  0x00007ffff7bfc010 in ?? () from /usr/local/lib/dri/i965_drv_video.so
#4  0x0000000000529e2a in call_init.part ()
#5  0x0000000000529fe5 in _dl_init ()
#6  0x000000000050702e in dl_open_worker ()
#7  0x0000000000505244 in _dl_catch_error ()
#8  0x00000000005069e9 in _dl_open ()
#9  0x00000000004b6797 in dlopen_doit ()
#10 0x0000000000505244 in _dl_catch_error ()
#11 0x00000000004b6be2 in _dlerror_run ()
#12 0x00000000004b67ee in __dlopen ()
#13 0x00000000004019e9 in va_openDriver (dpy=dpy@entry=0x811e90, driver_name=0x812370 "i965") at ../../git/va/va.c:235
#14 0x0000000000402ad3 in vaInitialize (dpy=dpy@entry=0x811e90, major_version=major_version@entry=0x7fffffffe430, minor_version=minor_version@entry=0x7fffffffe434) at ../../git/va/va.c:563
#15 0x0000000000400980 in main (argc=<optimized out>, argv=0x7fffffffe5d8) at ../../../git/test/vainfo/vainfo.c:120
(gdb) 
Last edited 13 months ago by jkqxz (previous) (diff)

comment:2 Changed 13 months ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords VA-API ffmpeg removed
Note: See TracTickets for help on using tickets.