After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752558 - 0.6.0 vaapipostproc regression: segfault
0.6.0 vaapipostproc regression: segfault
Status: RESOLVED FIXED
Product: gstreamer-vaapi
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gstreamer-vaapi maintainer(s)
gstreamer-vaapi maintainer(s)
Depends on:
Blocks: 754843
 
 
Reported: 2015-07-18 08:42 UTC by Francesco Frassinelli
Modified: 2015-09-10 15:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
backtrace (309.74 KB, application/gzip)
2015-07-18 08:42 UTC, Francesco Frassinelli
  Details
git bisect run scrpt (3.17 KB, application/x-shellscript)
2015-07-18 10:27 UTC, Francesco Frassinelli
  Details
Debug log (no colors, no timestamps) (485.29 KB, application/x-xz)
2015-07-21 14:07 UTC, Francesco Frassinelli
  Details
plugins: don't use gst_pad_get_allowed_caps() (1.63 KB, patch)
2015-07-21 16:57 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
Debug log, using autovideosrc (no colors, no timestamps) (566.85 KB, application/x-xz)
2015-07-21 18:04 UTC, Francesco Frassinelli
  Details

Description Francesco Frassinelli 2015-07-18 08:42:40 UTC
Created attachment 307655 [details]
backtrace

Hi,
I was testing gstreamer-vaapi 0.6.0 and I've found a regression: the very same command worked in 0.5.10.

Command (http://www.intel.co.uk/content/dam/www/public/us/en/documents/white-papers/video-encode-atom-e38xx-emgd-gstreamer-paper.pdf page 8):
$ gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=1800 ! video/x-raw,format=I420,width=640,height=480 ! vaapipostproc ! queue ! vaapiencode_h264 ! qtmux ! filesink location=test2.mp4

Info:
$ rpm -qa | grep 'vaapi\|libva' | sortgstreamer1-vaapi-0.6.0-1.fc22.x86_64
gstreamer1-vaapi-debuginfo-0.6.0-1.fc22.x86_64
libva-1.5.1-1.fc22.x86_64
libva-intel-driver-1.5.1-1.fc22.x86_64
libva-utils-1.5.1-1.fc22.x86_64
$ uname -r
4.2.0-0.rc2.git0.1.fc23.x86_64
$ cat /etc/fedora-release 
Fedora release 22 (Twenty Two)
Comment 1 Francesco Frassinelli 2015-07-18 10:27:54 UTC
Created attachment 307657 [details]
git bisect run scrpt

I wrote a little test in order to run git bisect automatically between 0.6.0 and 0.5.10 in order to detect the bad commit.

9799875df41c263a2614cae37cb7405a032928db "vaapidecode: delayed src caps negotiation " seems the bad one.
https://github.com/01org/gstreamer-vaapi/commit/9799875df41c263a2614cae37cb7405a032928db

I run ./configure the same way gstreamer1-vaapi Fedora package is configured, in order to use make install.

$ git bisect visualize 
commit 9799875df41c263a2614cae37cb7405a032928db
Author: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Date:   Thu Feb 26 12:24:55 2015 +0200

    vaapidecode: delayed src caps negotiation
    
    Currently the src caps are set immediately after the sink caps are set, but in
    that moment the pipeline might not fully constructed and the video sink has
    not negotiated its supported caps and features. As a consequence, in many cases
    of playback, the least optimized caps feature is forced. This is partially the
    responsible of bug #744039.
    
    Also, vaapidecode doesn't attend the reconfigure events from downstream,
    which is a problem too, since the video sink can be changed with different
    caps features.
    
    This patch delays the src caps, setting them until the first frame arrives to
    the decoder, assuming until that very moment the whole pipeline is already
    negotiated. Particularly, it checks if the src pad needs to be reconfigured,
    as a consequence of a reconfiguration event from downstream.
    
    A key part of this patch is the new GstVaapiCapsFeature
    GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED, which is returned when the src pad
    doesn't have a peer yet. Also, for a better report of the caps allowed
    through the src pad and its peer, this patch uses gst_pad_get_allowed_caps()
    instead of gst_pad_peer_query_caps() when looking for the preferred feature.
    
    v3: move the input_state unref to close(), since videodecoder resets at
    some events such as navigation.
    
    v4: a) the state_changed() callback replaces the input_state if the media
    changed, so this case is also handled.
        b) since the parameter ref_state in gst_vaapidecode_update_src_caps() is
    always the input_state, the parameter were removed.
        c) there were a lot of repeated code handling the input_state, so I
    refactored it with the function gst_vaapi_decode_input_state_replace().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744618
    
    Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
    Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
$ git bisect log
# bad: [daf5ea0be124febd808a7c5b51a74a873aaacf72] 0.6.0
# good: [a14ed0a78eba92ecf55789e631964f1663300d60] 0.5.10
git bisect start '0.6.0' '0.5.10'
# skip: [b3eccdb72be42469ad0d4fc45ffb6a8f7b3ebf25] decoder: hevc: cosmetics.
git bisect skip b3eccdb72be42469ad0d4fc45ffb6a8f7b3ebf25
# bad: [b1bbc087c1d00a30910673a61b2872cd629c9663] encoder: avoid GstVaapiCodedBuffer redefinition
git bisect bad b1bbc087c1d00a30910673a61b2872cd629c9663
# good: [8c93c842ef8a19e2b3c296d9e33c31c07afd6ab0] plugins: add support for BGRA textures.
git bisect good 8c93c842ef8a19e2b3c296d9e33c31c07afd6ab0
# bad: [ccccbf4b09c952306a154d343bf3b00722d43da7] gitmodules: Use https:// url instead of git:// for submodules.
git bisect bad ccccbf4b09c952306a154d343bf3b00722d43da7
# bad: [5425a05bd4638ed068d4f6e1a6f5e1d162a01288] vaapidecode: re-indent (gst-indent) gstvaapidecode.c
git bisect bad 5425a05bd4638ed068d4f6e1a6f5e1d162a01288
# bad: [e4f8d14979c4cdf18e5af5594ee02d59f3b3250b] vaapidecode: upload meta only if feature and allocation
git bisect bad e4f8d14979c4cdf18e5af5594ee02d59f3b3250b
# good: [3f28da7f5a224178d104992fe902212015dfb2e4] encoder: h264: add support for more than 2 views
git bisect good 3f28da7f5a224178d104992fe902212015dfb2e4
# bad: [9799875df41c263a2614cae37cb7405a032928db] vaapidecode: delayed src caps negotiation
git bisect bad 9799875df41c263a2614cae37cb7405a032928db
# first bad commit: [9799875df41c263a2614cae37cb7405a032928db] vaapidecode: delayed src caps negotiation
Comment 2 Víctor Manuel Jáquez Leal 2015-07-18 10:54:01 UTC
What's the error? are you using gstreamer 1.4? Which chipset is used?

I just tried with gstreamer 1.5 (current master) with haswell and that pipeline woks fine.
Comment 3 Víctor Manuel Jáquez Leal 2015-07-18 10:55:05 UTC
aha! a segfault... do you have a backtrace?
Comment 4 Víctor Manuel Jáquez Leal 2015-07-18 11:03:26 UTC
Does it work if you remove the queue between vaapispostroc and vaapiencode_h264?
Comment 5 Francesco Frassinelli 2015-07-18 11:16:31 UTC
reply to Víctor Manuel Jáquez Leal from comment #2)
> What's the error? are you using gstreamer 1.4? Which chipset is used?

Segfault.
$ rpm -q gstreamer1
gstreamer1-1.4.5-1.fc22.x86_64
$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Broadwell-U Integrated Graphics (rev 09)
$ cat /proc/cpuinfo | grep -m1 '^model name'
model name	: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz

> I just tried with gstreamer 1.5 (current master) with haswell and that
> pipeline woks fine.

I upgraded gstreamer and it still segfaults.
$ rpm -q gstreamer1
gstreamer1-1.5.2-1.fc23.x86_64

(In reply to Víctor Manuel Jáquez Leal from comment #3)
> aha! a segfault... do you have a backtrace?

It's attached to this bug: https://bugzilla.gnome.org/attachment.cgi?id=307655

(In reply to Víctor Manuel Jáquez Leal from comment #4)
> Does it work if you remove the queue between vaapispostroc and
> vaapiencode_h264?

Yes, it works.
Comment 6 Francesco Frassinelli 2015-07-18 11:18:43 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #4)
> Does it work if you remove the queue between vaapispostroc and
> vaapiencode_h264?

Sorry, it doesn't. I said yes because I removed vaapispostroc instead of queue.
Comment 7 sreerenj 2015-07-20 09:05:15 UTC
Strange! Issue is not reproducible for me !!
Tested with 1.4.3 and 1.5(git master) on my HSW machine...
Comment 8 Víctor Manuel Jáquez Leal 2015-07-20 10:14:40 UTC
(In reply to sreerenj from comment #7)
> Strange! Issue is not reproducible for me !!
> Tested with 1.4.3 and 1.5(git master) on my HSW machine...

I have just tested with gstreamer 1.4.5 / HSW and works.

Reading the backtrace, it looks like a very pathological situation: vaapipostproc's src pad queries itself recursively until all the memory is consumed.

I can't imagine which circumstances can lead to the vaapostproc's src pad could query itself, just a bug in gst_pad_get_allowed_caps() in your setup.
Comment 9 Francesco Frassinelli 2015-07-21 08:53:55 UTC
Is there something I can do in order to help you?
Comment 10 Víctor Manuel Jáquez Leal 2015-07-21 09:09:20 UTC
(In reply to Francesco Frassinelli from comment #9)
> Is there something I can do in order to help you?

mmmhh... can you upload a debug log??

Something like 

gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=1800 ! video/x-raw,format=I420,width=640,height=480 ! vaapipostproc ! queue ! vaapiencode_h264 ! qtmux ! filesink location=test2.mp4 --gst-debug="vaapipostproc:5,*:3"
Comment 11 Francesco Frassinelli 2015-07-21 14:07:26 UTC
Created attachment 307828 [details]
Debug log (no colors, no timestamps)

(In reply to Víctor Manuel Jáquez Leal from comment #10)
> gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=1800 !
> video/x-raw,format=I420,width=640,height=480 ! vaapipostproc ! queue !
> vaapiencode_h264 ! qtmux ! filesink location=test2.mp4
> --gst-debug="vaapipostproc:5,*:3"

No output from vaapipostproc.
I tried to generate a debug log with this command:

$ gst-launch-1.0 -e v4l2src device=/dev/video0 num-buffers=1800 ! video/x-raw,format=I420,width=640,height=480 ! vaapipostproc ! queue ! vaapiencode_h264 ! qtmux ! filesink location=test2.mp4  --gst-debug="*:5" --gst-debug-no-color |& cut -b31- | xz -ec -T 4 > vaapipostproc-debug.log.xz

The uncompressed file is abot ~380 MB, while the compressed one is less than 500 KB. You can use xzcat vaapipostproc-debug.log.xz | less or similar in order to read it.
Comment 12 Víctor Manuel Jáquez Leal 2015-07-21 16:56:56 UTC
It seems that gst_pad_get_allowed_caps() leads to loops in the case of basetransform elements. But I still don't understand why. I see the loop in the log but not the reason of if.

It is strange that it is not happening to Sree neither to me.

Can you try with autovideosrc??
Comment 13 Víctor Manuel Jáquez Leal 2015-07-21 16:57:35 UTC
Created attachment 307844 [details] [review]
plugins: don't use gst_pad_get_allowed_caps()

gst_pad_get_allowed_caps() query the pad and the peer pad. In the case
decoders, that is OK, but in the case of the postproc might lead loops,
since the gst_base_transform_query_caps() forwards the query upstream
and forth.

Instead of gst_pad_get_allowed_caps() we only query the peer with
gst_pad_peer_query_caps() using the pad's template as filter.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Comment 14 Víctor Manuel Jáquez Leal 2015-07-21 16:58:58 UTC
Francesco, can you try also with the posted patch?

I'm not sure if it is really needed, though...
Comment 15 Francesco Frassinelli 2015-07-21 18:04:24 UTC
Created attachment 307848 [details]
Debug log, using autovideosrc (no colors, no timestamps)

(In reply to Víctor Manuel Jáquez Leal from comment #12)
> Can you try with autovideosrc??

$ gst-launch-1.0 -e autovideosrc ! video/x-raw,format=I420,width=640,height=480 ! vaapipostproc ! queue ! vaapiencode_h264 ! qtmux ! filesink location=test2.mp4  --gst-debug="*:5" --gst-debug-no-color |& cut -b31- | xz -ec -T 4 > vaapipostproc-debug.log.xz

No segfault, exit code is 0.

(In reply to Víctor Manuel Jáquez Leal from comment #14)
> Francesco, can you try also with the posted patch?
> 
> I'm not sure if it is really needed, though...

Patch applied to 0.6.0 and I got no segfault :) Tested with v4l2src and ximagesrc, everything seem to work correctly!
Comment 16 Víctor Manuel Jáquez Leal 2015-07-22 09:10:51 UTC
(In reply to Francesco Frassinelli from comment #15)
> Created attachment 307848 [details]
> Debug log, using autovideosrc (no colors, no timestamps)
> 
> (In reply to Víctor Manuel Jáquez Leal from comment #12)
> > Can you try with autovideosrc??
> 
> $ gst-launch-1.0 -e autovideosrc !
> video/x-raw,format=I420,width=640,height=480 ! vaapipostproc ! queue !
> vaapiencode_h264 ! qtmux ! filesink location=test2.mp4  --gst-debug="*:5"
> --gst-debug-no-color |& cut -b31- | xz -ec -T 4 > vaapipostproc-debug.log.xz
> 
> No segfault, exit code is 0.

Weird. Perhaps it is a bug in your camera's software stack. Dunno.

> 
> (In reply to Víctor Manuel Jáquez Leal from comment #14)
> > Francesco, can you try also with the posted patch?
> > 
> > I'm not sure if it is really needed, though...
> 
> Patch applied to 0.6.0 and I got no segfault :) Tested with v4l2src and
> ximagesrc, everything seem to work correctly!

With ximagesrc didn't work either?
Comment 17 Francesco Frassinelli 2015-07-22 09:45:21 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #16)
> (In reply to Francesco Frassinelli from comment #15)
> > (In reply to Víctor Manuel Jáquez Leal from comment #14)
> > > Francesco, can you try also with the posted patch?
> > > 
> > > I'm not sure if it is really needed, though...
> > 
> > Patch applied to 0.6.0 and I got no segfault :) Tested with v4l2src and
> > ximagesrc, everything seem to work correctly!
> 
> With ximagesrc didn't work either?

I tested ximagesrc changing the pipeline a little bit, and it work even without the patch.

Do you think that this bug should be reassigned to v4l2src or something else?
Comment 18 Víctor Manuel Jáquez Leal 2015-07-22 09:58:37 UTC
(In reply to Francesco Frassinelli from comment #17)
> 
> Do you think that this bug should be reassigned to v4l2src or something else?

Actually, I am not sure.
Comment 19 Víctor Manuel Jáquez Leal 2015-08-04 17:17:53 UTC
Attachment 307844 [details] pushed as c76fe74 - plugins: don't use gst_pad_get_allowed_caps()