Bug 82466 - VAAPI / Intel i965 driver crash: FFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
Summary: VAAPI / Intel i965 driver crash: FFmpeg::Open() Using codec: H.264 / AVC / MP...
Status: RESOLVED FIXED
Alias: None
Product: libva
Classification: Unclassified
Component: intel (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Gwenole Beauchesne
QA Contact: Sean V Kelley
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-11 13:14 UTC by Pierluigi
Modified: 2014-08-18 15:10 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
decoder: h264: fix RefPicList0/1 without frame in DPB (1.15 KB, patch)
2014-08-12 11:04 UTC, Gwenole Beauchesne
Details | Splinter Review

Description Pierluigi 2014-08-11 13:14:48 UTC
Using xbmc with ffmpeg-2.3.1 and opening a stream from tv channels in HD (FFmpeg :: Open () Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10), this problem occurs systematically :

Program terminated with signal SIGSEGV, Segmentation fault.
# 0 0x00007f73901eb5b9 in ?? () From /usr/lib/dri/i965_drv_video.so

following the links to:

crash log of xbmc
http://paste.ubuntu.com/8016170/

LIBVA_TRACE:
http://paste.ubuntu.com/8016180/

for other details:

http://forum.xbmc.org/showthread.php?tid=201412&pid=1770979#pid1770979


My system info:
libva info: VA-API version 0.35.2
libva info: va_getDriverName () returns 0
info libva: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver () returns 0
vainfo: VA-API version: 00:35 (libva 1.3.2.pre1)
vainfo: Driver version: Intel i965 driver for Intel (R) Sandybridge Desktop - 1.3.3.pre1
vainfo: Supported profile and entrypoints
       VAProfileMPEG2Simple: VAEntrypointVLD
       VAProfileMPEG2Main: VAEntrypointVLD
       VAProfileH264ConstrainedBaseline: VAEntrypointVLD
       VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
       VAProfileH264Main: VAEntrypointVLD
       VAProfileH264Main: VAEntrypointEncSlice
       VAProfileH264High: VAEntrypointVLD
       VAProfileH264High: VAEntrypointEncSlice
       VAProfileH264StereoHigh: VAEntrypointVLD
       VAProfileVC1Simple: VAEntrypointVLD
       VAProfileVC1Main: VAEntrypointVLD
       VAProfileVC1Advanced: VAEntrypointVLD
       VAProfileNone: VAEntrypointVideoProc

Thank you.
regards
Comment 1 Pierluigi 2014-08-11 13:51:55 UTC
An additional information:
downgrading ffmpeg to an older version 2.2.x does not produce this error.
Bye
Comment 2 Pierluigi 2014-08-11 14:52:23 UTC
One other additional information.

No crash downgrading to:

libva info: VA-API version 0.35.1
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_35
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.35 (libva 1.3.1)
vainfo: Driver version: Intel i965 driver - 1.3.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
Comment 3 Peter Frühberger 2014-08-11 15:09:37 UTC
Can you try to bisect between 1.3.1 and 1.3.2?

checkout master branch and choose 1.3.1 commit as good - from there it should only be max 7 steps.
Comment 4 Pierluigi 2014-08-12 08:17:21 UTC
I've got tried.
This is the result:
git bisect start
# Bad: [Commit:82d2ed8] Add more check of H264 slice param to avoid GPU hang Caused by the incorrect parameter
git bisect bad Commit:82d2ed8
# Good: [Commit:cc40368] Intel driver 1.3.2
git bisect good Commit:cc40368
# Good: [Commit:da8a7e9] surface: drop SURFACE_DISPLAYED flag.
git bisect good Commit:da8a7e9
# Bad: [Commit:107274f] H264_Encoding: Add the support of packed slice header to be flexible
git bisect bad Commit:107274f
# Bad: [Commit:772e942] H264_Encoding: Parse the packed header data from user to fix the hacked code of HW skip bytes
git bisect bad Commit:772e942
# Bad: [Commit:143c539] decoder: h264: fix frame store logic for MVC.
git bisect bad Commit:143c539
# Good: [Commit:d2262e3] decoder: h264: Improve AVC_REF_IDX_STATE for MVC.
git bisect good Commit:d2262e3
# First bad commit: [Commit:143c539] decoder: h264: fix frame store logic for MVC.

reverting from the master "first bad commit: [Commit:143c539] decoder: h264: fix frame store for MVC logic." crash does not occur.
Unfortunately,the code of the regression is quite complex for my knowledge ...
Bye
Comment 5 Peter Frühberger 2014-08-12 10:50:34 UTC
Thanks you very much. I will subscribe the committer of this code into that bugreport.

http://cgit.freedesktop.org/vaapi/intel-driver/commit/?id=143c53900943c660390122f7fa4a1c5705798fdd
Comment 6 Gwenole Beauchesne 2014-08-12 11:04:22 UTC
Created attachment 104490 [details] [review]
decoder: h264: fix RefPicList0/1 without frame in DPB

Here is one patch hanging in my local tree and was not pushed for some reason. Could you please give it a try? Thanks.
Comment 7 Gwenole Beauchesne 2014-08-12 11:33:30 UTC
BTW, if it works for you with the patch, then please try to provide the video somewhere. That's surely a bug in there, but the driver should not crash for sure either.
Comment 8 Pierluigi 2014-08-12 12:25:09 UTC
Patch applied.
It works!
The problem was only present on encrypted satellite streams from channels in HD (Italian national TV). Presumably you're right that there is something non-standard. I will try to capture a few seconds of the stream to provide it as an example. I agree with you that this condition must be provided for in the code, it may not be an isolated case.

Thanks very much to all
Ciao.
Comment 10 Gwenole Beauchesne 2014-08-18 14:00:32 UTC
(In reply to comment #9)
> Sample video:
> 
> https://drive.google.com/file/d/0B-ddyRHhx23pTFlSN3RtRllxdXc/edit?usp=sharing

Thanks. Tested with gstreamer-vaapi, and without the previously attached patch, it works. It is so, because gst will try to decode from the first valid I-frame, whereas FFmpeg will attempt to decode whatever it has at any point. So, since previous frames are missing (streaming, seek), you can't correctly decode the stream, unless you tolerate artifacts.

Anyway, I have now pushed the patch to both "master" and "staging" branches.
Comment 11 Gwenole Beauchesne 2014-08-18 14:00:46 UTC
commit 8387e32247822af8366f93c683ed59bb2198283e
Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date:   Wed Jun 18 13:11:48 2014 +0200

    decoder: h264: fix RefPicList0/1 without frame in DPB.
    
    Some bitstreams (e.g. truncated, or non conformant), or bugs in codec
    layers, would incorrectly make decoders to fill in the RefPicList0/1
    lists with surfaces that have not received any content yet.
    
    There is no reason for the driver to crash in such cases.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=82466
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.