Opened 6 years ago

Closed 6 years ago

Last modified 6 years 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


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 \
 nasm \
 pkg-config \

git pull
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" \



# ./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/
Segmentation fault (core dumped)

gdb output is
valgrind output is

Change History (2)

comment:1 by jkqxz, 6 years ago

Resolution: invalid
Status: newclosed

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 <>
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:
Find the GDB manual and other documentation resources online at:
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/
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/".

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/
#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
Last edited 6 years ago by jkqxz (previous) (diff)

comment:2 by Carl Eugen Hoyos, 6 years ago

Component: ffmpegundetermined
Keywords: VA-API ffmpeg removed
Note: See TracTickets for help on using tickets.