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 797239 - qtdemux: Crash when playing smooth-streaming
qtdemux: Crash when playing smooth-streaming
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal blocker
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 797309 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2018-10-03 01:21 UTC by Nicolas Dufresne (ndufresne)
Modified: 2018-10-20 11:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
qtdemux: Don't switch active streams and old streams ... (1.65 KB, patch)
2018-10-04 02:28 UTC, Seungha Yang
none Details | Review
qtdemux: Don't switch active streams and old streams ... (1.68 KB, patch)
2018-10-05 10:19 UTC, Seungha Yang
none Details | Review
[1/4] qtdemux: Make function foreach method friendly (2.20 KB, patch)
2018-10-07 11:11 UTC, Seungha Yang
committed Details | Review
[2/4] qtdemux: Make QtDemuxStream refcounted structure (6.20 KB, patch)
2018-10-07 11:12 UTC, Seungha Yang
committed Details | Review
[3/4] qtdemux: Use GPtrArray to store QtDemuxStream structure (41.44 KB, patch)
2018-10-07 11:13 UTC, Seungha Yang
committed Details | Review
[4/4] qtdemux: Don't switch active streams and old streams ... (1.57 KB, patch)
2018-10-07 11:14 UTC, Seungha Yang
committed Details | Review
qtdemux: Don't use g_ptr_array_find_with_equal_func() (1.96 KB, patch)
2018-10-19 15:30 UTC, Seungha Yang
none Details | Review
qtdemux: Fix broken build due to g_ptr_array_find_with_equal_func() (1.59 KB, patch)
2018-10-20 00:17 UTC, Seungha Yang
committed Details | Review

Description Nicolas Dufresne (ndufresne) 2018-10-03 01:21:42 UTC
Just stumbled across this crash. The stream list is empty, but n_streams says 1.

gst-play-1.0 "http://playready.eastus2.cloudapp.azure.com/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism/Manifest"

(gdb) bt
  • #0 gst_qtdemux_setcaps
    at ../gst/isomp4/qtdemux.c line 2039
  • #1 gst_qtdemux_handle_sink_event
    at ../gst/isomp4/qtdemux.c line 2428
  • #2 gst_pad_send_event_unchecked
    at ../gst/gstpad.c line 5757
  • #3 gst_pad_push_event_unchecked
    at ../gst/gstpad.c line 5402
  • #4 push_sticky
    at ../gst/gstevent.h line 438
  • #5 events_foreach
    at ../gst/gstpad.c line 608
  • #6 check_sticky
    at ../gst/gstpad.c line 3977
  • #7 gst_pad_push_event
    at ../gst/gstpad.c line 5533
  • #8 gst_single_queue_push_one
    at ../plugins/elements/gstmultiqueue.c line 1692
  • #9 gst_multi_queue_loop
    at ../plugins/elements/gstmultiqueue.c line 1963
  • #10 gst_task_func
    at ../gst/gsttask.c line 328
  • #11 g_thread_pool_thread_proxy
  • #12 g_thread_proxy
  • #13 start_thread
  • #14 clone

Comment 1 Edward Hervey 2018-10-03 12:40:45 UTC
This *might* have been introduced by:

commit d72a7c038c6a1be3f865afa9b50f2878d02d87ba
Author: Seungha Yang <seungha.yang@navercorp.com>
Date:   Tue May 8 20:26:41 2018 +0900

    qtdemux: Try to expose whenever got new moov or new stream-start
    
    Whenever got new moov or new stream-start,
    demux will try to expose new pad by following rule.
    
    Comparing stream-id in the current moov with previous one, then
    * If matched stream-id is found from previous one,
      reuse existing pad (most common case)
    * Otherwise, expose new pad with new stream-start
    * No more used stream will be freed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684790
Comment 2 Nicolas Dufresne (ndufresne) 2018-10-03 15:57:09 UTC
Do you know which version this was merged in ? The bug wasn't updated when it got marked resolved.
Comment 3 Nicolas Dufresne (ndufresne) 2018-10-03 16:03:24 UTC
Answer is master, so 1.15.1 is target, it's updated now. I just tested on 1.14 and indeed it worked.
Comment 4 Seungha Yang 2018-10-04 02:28:10 UTC
Created attachment 373841 [details] [review]
qtdemux: Don't switch active streams and old streams ...

... before the old streams is not exposed yet for MSS stream.

In case of DASH, newly configured streams will be exposed
whenever demux got moov without delay.
Meanwhile, since there is no moov box in MSS stream,
the caps will act like moov. Then, there is delay for exposing new pads
until demux got the first moof.

So, following scenario is possible only for MSS but not for DASH,
STREAM-START -> CAPS -> (configure stream but NOT EXPOSED YET)
-> STREAM-START-> CAPS (configure stream again).

In above scenario, we can reuse old stream without any stream reconfigure.
Comment 5 Edward Hervey 2018-10-04 12:00:22 UTC
Review of attachment 373841 [details] [review]:

::: gst/isomp4/qtdemux.c
@@ +2458,3 @@
+        demux->old_streams =
+            g_list_concat (demux->old_streams, demux->active_streams);
+        demux->active_streams = NULL;

Shouldn't we also set n_streams to 0 here ? Otherwise it means active_streams and n_streams are out of sync
Comment 6 Nicolas Dufresne (ndufresne) 2018-10-04 13:22:22 UTC
Is n_streams strictly the size of the list? If so, it might be good looking into using GQueue ?
Comment 7 Seungha Yang 2018-10-05 10:13:20 UTC
(In reply to Nicolas Dufresne (ndufresne) from comment #6)
> Is n_streams strictly the size of the list? If so, it might be good looking
> into using GQueue ?

because n_streams should be the size of the list, I feel the use of GQueue can make code a little simpler. I'll look at it more.
Comment 8 Seungha Yang 2018-10-05 10:19:58 UTC
Created attachment 373853 [details] [review]
qtdemux: Don't switch active streams and old streams ...
Comment 9 Sebastian Dröge (slomo) 2018-10-05 10:22:16 UTC
Or GPtrArray. Linked lists are usually the wrong data structure :)
Comment 10 Seungha Yang 2018-10-07 11:11:39 UTC
Created attachment 373863 [details] [review]
[1/4] qtdemux: Make function foreach method friendly
Comment 11 Seungha Yang 2018-10-07 11:12:43 UTC
Created attachment 373864 [details] [review]
[2/4] qtdemux: Make QtDemuxStream refcounted structure

This a prework for porting GPtrArray.
Refcounting will help the use of g_ptr_array_new_with_free_func()
with QtDemuxStream structure
Comment 12 Seungha Yang 2018-10-07 11:13:34 UTC
Created attachment 373865 [details] [review]
[3/4] qtdemux: Use GPtrArray to store QtDemuxStream structure

GPtrArray has less overhead than linked list and the length also
can be auto updated by using it.
Comment 13 Seungha Yang 2018-10-07 11:14:11 UTC
Created attachment 373866 [details] [review]
[4/4] qtdemux: Don't switch active streams and old streams ...
Comment 14 Seungha Yang 2018-10-07 11:15:47 UTC
Unit test (qtdemux/qtmux) and gst-validate-launch were passed with new patches.
Comment 15 Edward Hervey 2018-10-19 12:47:50 UTC
perfect ! Thanks for that.
Comment 16 Edward Hervey 2018-10-19 13:49:26 UTC
Seungha, unfortunately this uses glib API which isn't present in the required glib version we use:

* g_ptr_array_find_with_equal_func : this was introduced in glib 2.54
Comment 17 Seungha Yang 2018-10-19 14:09:33 UTC
(In reply to Edward Hervey from comment #16)
> Seungha, unfortunately this uses glib API which isn't present in the
> required glib version we use:
> 
> * g_ptr_array_find_with_equal_func : this was introduced in glib 2.54

My bad :( I'll upload new patch soon
Comment 18 Seungha Yang 2018-10-19 15:30:04 UTC
Created attachment 373975 [details] [review]
qtdemux: Don't use g_ptr_array_find_with_equal_func()

g_ptr_array_find_with_equal_func was introduced in glib 2.54
which is a higher version than our minimum required one.
Comment 19 Tim-Philipp Müller 2018-10-19 18:18:47 UTC
Comment on attachment 373975 [details] [review]
qtdemux: Don't use g_ptr_array_find_with_equal_func()

>+/* g_ptr_array_find_with_equal_func is available since 2.54,
>+ * replacement until we can depend unconditionally on the real one in GLib */
>+static gboolean
>+qtdemux_ptr_array_find_with_equal_func (GPtrArray * haystack,
>+    gconstpointer needle, GEqualFunc equal_func, guint * index_)
>+{
>...
>+}

I think this should be done conditionally, like this:

#if !GLIB_CHECK_VERSION(2,56,0)
#define g_ptr_array_find_with_equal_func qtdemux_ptr_array_find_with_equal_func
>+static gboolean
>+g_ptr_array_find_with_equal_func (GPtrArray * haystack,
>+    gconstpointer needle, GEqualFunc equal_func, guint * index_)
>+{
>...
>+}
#endif

which makes it easier to grep for it later when we bump the GLib req, and avoids the duplication if GLib is new enough.
Comment 20 Seungha Yang 2018-10-20 00:17:35 UTC
Created attachment 373977 [details] [review]
qtdemux: Fix broken build due to g_ptr_array_find_with_equal_func()

Modify to use GLIB_CHECK_VERSION(2,54,0)
Comment 21 Sebastian Dröge (slomo) 2018-10-20 01:45:57 UTC
*** Bug 797309 has been marked as a duplicate of this bug. ***
Comment 22 Tim-Philipp Müller 2018-10-20 11:39:53 UTC
Comment on attachment 373977 [details] [review]
qtdemux: Fix broken build due to g_ptr_array_find_with_equal_func()

Thanks!

commit 7bce030be35532a1a2025bf5fea0d47dd822adb5 (HEAD -> master)
Author: Seungha Yang <seungha.yang@navercorp.com>
Date:   Sat Oct 20 00:10:04 2018 +0900

    qtdemux: Fix build with GLib versions < 2.54
    
    g_ptr_array_find_with_equal_func was introduced in glib 2.54
    which is a higher version than our minimum required one.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=797239