intel / libva

Libva is an implementation for VA-API (Video Acceleration API)
http://intel.github.io/libva/
Other
665 stars 303 forks source link

vaDisplayIsValid random Segmentation fault #36

Open alexge233 opened 7 years ago

alexge233 commented 7 years ago

Hi,

I'm using libfreenect2 which is using libva for hardware encoding/decoding AFAIK, and I've opened an issue there as well. System is Ubuntu 16.04 amd64, and I've got libva installed from apt-get, version 1.7.0-1.

I keep getting random segmentation faults:

[New Thread 0x7fffd178a700 (LWP 23148)]
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 8 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @2:5 with serial 001680660547
[Info] [Freenect2Impl] found 1 devices

Thread 1 "mario_node" received signal SIGSEGV, Segmentation fault.
0x00007fffeeda3347 in vaDisplayIsValid () from /usr/lib/x86_64-linux-gnu/libva.so.1
(gdb) bt
#0  0x00007fffeeda3347 in vaDisplayIsValid () from /usr/lib/x86_64-linux-gnu/libva.so.1
#1  0x00007ffff576a5c7 in libfreenect2::VaapiRgbPacketProcessorImpl::initializeVaapi() () from /home/mario/freenect2/lib/libfreenect2.so.0.2
#2  0x00007ffff5769408 in libfreenect2::VaapiRgbPacketProcessor::VaapiRgbPacketProcessor() () from /home/mario/freenect2/lib/libfreenect2.so.0.2
#3  0x00007ffff5756ee5 in libfreenect2::CpuPacketPipeline::CpuPacketPipeline() () from /home/mario/freenect2/lib/libfreenect2.so.0.2
#4  0x0000000000413e60 in freenect2::freenect2() ()

I took a look into their code, and the offending code appear to be:

  bool initializeVaapi()
  {
    /* Open display */
    static const char *drm_devices[] = {
      "/dev/dri/renderD128",
      "/dev/dri/card0",
      NULL,
    };
    for (int i = 0; drm_devices[i]; i++) {
      drm_fd = open(drm_devices[i], O_RDWR);
      if (drm_fd < 0)
        continue;
      display = vaGetDisplayDRM(drm_fd);
      if (vaDisplayIsValid(display))
        break;
      close(drm_fd);
      drm_fd = -1;
      display = NULL;
    }
    CHECK_COND(vaDisplayIsValid(display));

Please bear in mind the code (library) is executing under ssh but there is a gdm running, drivers are loaded, and the /dev/dri/* do exist.

xhaihao commented 7 years ago

@alexge233 sorry for slow response, all pointers are checked against NULL in vaDisplayIsValid(), so it is weird that you experienced this issue. Could you help to debug this issue with gdb when you encounter this issue again?

alexge233 commented 7 years ago

@xhaihao I can force it by re-compiling libfreenect with libva enabled. If I run it enough times it happens. Are there debug symbols in apt-get for va?

xhaihao commented 7 years ago

Thanks @alexge233 , you may try libva1-dbg or if possible, you can build the library from source code. you can download the release tarball from https://github.com/01org/libva/releases,

alexge233 commented 7 years ago

Hi @xhaihao on Ubuntu 16.04 there is no libva1-dbg, have you got a ppa repository?

xhaihao commented 7 years ago

@alexge233 Sorry I gave you wrong information. I saw libva1-dbg in the list bash-completion gave me when I typed 'apt-get install libva\<TAB>', I thought libva1-dbg is available to install.

FocusLuo commented 7 years ago

Assigned to P4 priority based on our bug scrub meeting

xhaihao commented 7 years ago

@alexge233 Do you have a chance to debug this problem? I don't have the environment to reproduce this issue.

alexge233 commented 7 years ago

No sorry, we've changed platform and moved on to a tegra.

juraj-chripko commented 5 years ago

Hi, it looks like I'm getting same error when trying to encode webp. I have build both static and dynamic library from my sources and using that library in other program. When I use static library, everything works just fine, but using shared library I get segfault in vaDisplayIsValid, which is odd, because I thought program using libva has to be linked dynamically to load driver. I tried debugging and display variable (which i got from va_open_display() function from libva-utils/common/libva-display) is not NULL, but I cannot acces other display object variables. I can send you crash dump, or my code, but it's mostly copied from encode example from libva-utils.