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 755918 - decodebin: Refactor code to remove assertion errors
decodebin: Refactor code to remove assertion errors
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 1.7.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-10-01 06:36 UTC by Vineeth
Modified: 2016-02-17 08:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix assertion errors (1.64 KB, patch)
2015-10-01 06:37 UTC, Vineeth
none Details | Review
fix get_topology logic to remove possible assertion errors (2.11 KB, patch)
2015-11-23 06:16 UTC, Vineeth
committed Details | Review

Description Vineeth 2015-10-01 06:36:27 UTC
While getting topology, if the chain pad caps is not fixed, then the caps is being unreffed and passed on the structure id set. But passing NULL to structure_id_set results in assertion errors.
And get_topology can return NULL value, which on being passed to create message
will result in assertion error. Check if topology is valid before using it
Comment 1 Vineeth 2015-10-01 06:37:24 UTC
Created attachment 312466 [details] [review]
fix assertion errors
Comment 2 Sebastian Dröge (slomo) 2015-10-02 13:39:05 UTC
Review of attachment 312466 [details] [review]:

::: gst/playback/gstdecodebin2.c
@@ +4449,3 @@
       gst_caps_unref (caps);
+      gst_structure_free (u);
+      return NULL;

Seems a bit extreme to directly return NULL here. What about returning incomplete information instead?

Also how can you even get unfixed caps here?

@@ +4468,3 @@
   s = gst_decode_chain_get_topology (dbin->decode_chain);
 
+  if (s) {

When does it return NULL? Should probably cause a GST_WARNING_OBJECT() somewhere.
Comment 3 Vineeth 2015-10-05 02:55:42 UTC
(In reply to Sebastian Dröge (slomo) from comment #2)
> Review of attachment 312466 [details] [review] [review]:
> 
> ::: gst/playback/gstdecodebin2.c
> @@ +4449,3 @@
>        gst_caps_unref (caps);
> +      gst_structure_free (u);
> +      return NULL;
> 
> Seems a bit extreme to directly return NULL here. What about returning
> incomplete information instead?
> 
> Also how can you even get unfixed caps here?
> 
I am not sure if this scenario is possible.
While debugging another issue, just saw this piece of code,
where when the caps is unfixed, then 
      gst_caps_unref (caps);
      caps = NULL;
is being done, and the same will be passed on to
  gst_structure_id_set (u, topology_caps, GST_TYPE_CAPS, caps, NULL);
Passing NULL to this will cause assertion error.

By incomplete information you mean all other information without caps right?
But not sure if that makes much sense without caps :)


> @@ +4468,3 @@
>    s = gst_decode_chain_get_topology (dbin->decode_chain);
>  
> +  if (s) {
> 
> When does it return NULL? Should probably cause a GST_WARNING_OBJECT()
> somewhere.
Again this is a highly unlikely scenario :)
In the function gst_decode_chain_get_topology

  if (G_UNLIKELY ((chain->endpad || chain->deadend)
          && (chain->endcaps == NULL))) {
    GST_WARNING ("End chain without valid caps !");
    return NULL;
  }
So here it might return NULL. Hence that check was needed
Comment 4 Sebastian Dröge (slomo) 2015-10-05 11:04:52 UTC
How do you reproduce this issue? What are the unfixed caps you get there? That seems like the main bug here.
Comment 5 Vineeth 2015-10-05 12:11:52 UTC
:)
I did not reproduce this issue...

I have another issue where gst-validate complains about caps mismatch similar to bug id 752690..

So i was just going through the decodebin code and found this code.. this is just cosmetic changes..
Comment 6 Sebastian Dröge (slomo) 2015-10-05 13:10:02 UTC
While it is somewhat cosmetic, we should find the reason why it gets into that situation. It shouldn't happen :)
Comment 7 Vineeth 2015-11-23 06:16:21 UTC
Created attachment 316073 [details] [review]
fix get_topology logic to remove possible assertion errors

gst_decode_chain_get_topology will be called when the decode chain is being exposed. At this time the chain caps will be fixed. So there is no need to check if the caps is fixed or not.
And removing duplicate gst_pad_get_current_caps function, as the same will be already done in get_pad_caps. And if get_pad_caps returns NULL(which is unlikely), just return the incomplete caps. Because passing NULL caps to 
   gst_structure_id_set (u, topology_caps, GST_TYPE_CAPS, caps, NULL);
will cause assertion errors.
And in case endchain doesnt have any valid caps(which is again unlikely), then get_topology returns NULL, which will cause assertion errors when passed to gst_message_new_element. Hence adding a precautionary check.
Comment 8 Vineeth 2015-12-22 06:25:38 UTC
ping :)
Comment 9 Sebastian Dröge (slomo) 2015-12-22 09:05:23 UTC
Review of attachment 316073 [details] [review]:

When exactly will this return NULL caps? The only case I currently think of is when decodebin is being shut down while this code runs. Anything else? Like missing decoders?

Makes sense otherwise.
Comment 10 Vineeth 2015-12-24 07:13:24 UTC
nope.. I dont think if there are missing decoders, it will even come till posting the topology message.
Comment 11 Sebastian Dröge (slomo) 2015-12-24 08:42:29 UTC
So what exactly is the reason for the NULL caps, when does it happen? :) I'm worried that there might be another bug that is only hidden by your patch.
Comment 12 Sebastian Dröge (slomo) 2016-02-16 11:36:25 UTC
Ping?
Comment 13 Vineeth 2016-02-17 01:56:10 UTC
as mentioned in previous comments, i don't see any reason why the caps will be NULL, other than maybe when decodebin shuts down when this code is running.
It was already added just as a precautionary measure. So just adding extra precautionary checks. 


The only change needed here is replacing the below block of code

  /* Caps that resulted in this chain */
  caps = gst_pad_get_current_caps (chain->pad);
  if (!caps) {
    caps = get_pad_caps (chain->pad);
    if (G_UNLIKELY (!gst_caps_is_fixed (caps))) {
      GST_ERROR_OBJECT (chain->pad,
          "Couldn't get fixed caps, got %" GST_PTR_FORMAT, caps);
      gst_caps_unref (caps);
      caps = NULL;
    }
  }
...

with
caps = get_pad_caps (chain->pad);

since get_pad_caps already handles gst_pad_get_current_caps, so it will become duplicated calls


Rest all is not needed and highly impossible scenarios. Hence the addition of G_UNLIKELY :)

Actually it is not even a major issue, so i don't mind to close this issue as invalid.
Comment 14 Sebastian Dröge (slomo) 2016-02-17 08:50:48 UTC
commit 5d78aab81081d157826e0228dc310b4fae9eb8e0
Author: Vineeth T M <vineeth.tm@samsung.com>
Date:   Mon Nov 23 15:06:02 2015 +0900

    decodebin: return incomplete topology if decode chains' cap could not be obtained
    
    When getting caps of the decode chain, in get_topology, the caps are being
    checked if fixed or not. But get_topology will be called when the decode is
    chain is being exposed and hence it will always be fixed. Hence removing the
    check for fixed caps. Removing gst_pad_get_current_caps for the chain->pad, as
    get_pad_caps will again call the same api.
    
    And get_topology can return NULL value if currently shutting down the
    pipeline, which on being passed to create message will result in assertion
    error. Check if topology is valid before using it
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755918
Comment 15 Sebastian Dröge (slomo) 2016-02-17 08:51:10 UTC
I see, that makes sense then :)