gst_element_set_state deadlock

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

gst_element_set_state deadlock

tobatrance
hi.

i'm using ubuntu 16.04 and gstreamer 1.8.3. i'm using the pipeline filesrc -> decodebin -> appsink. i'm creating and destroying  multiple of these pipelines within short time and playing different videos concurrently. before destroying the pipeline I pause them and afterwards set them to GST_STATE_NULL. somewhen it happens that gst_element_set_state(pipeline, GST_STATE_NULL) does not return. in this log i'm running two 4k videos. first comes the backtrace of the mainloop thread. the mutex in frame 1 is a p_thread_mutex.

#0  0x00007f3fc4f0326d in __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007f3fc4efce42 in __GI___pthread_mutex_lock (mutex=0x7f3f30041a20) at ../nptl/pthread_mutex_lock.c:115
        id = -990891411
        __PRETTY_FUNCTION__ = "__pthread_mutex_lock"
        type = 1
        id = <optimized out>
#2  0x00007f3fc61c269d in activate_mode_internal (new_mode=GST_PAD_MODE_NONE, pad=0x7f3f900ff8f0 [GstPad]) at gstpad.c:1014
        res = 0
        old = <optimized out>
        new = <optimized out>
        dir = <optimized out>
        peer = <optimized out>
        __PRETTY_FUNCTION__ = "activate_mode_internal"
#3  0x00007f3fc61c269d in activate_mode_internal (pad=pad@entry=0x7f3f900ff8f0 [GstPad], parent=parent@entry=0x7f3f3004c1a0 [GstVaapiDecode], mode=mode@entry=GST_PAD_MODE_PUSH, active=active@entry=0) at gstpad.c:1185
        res = 0
        old = <optimized out>
        new = <optimized out>
        dir = <optimized out>
        peer = <optimized out>
        __PRETTY_FUNCTION__ = "activate_mode_internal"
#4  0x00007f3fc61c2dcd in gst_pad_set_active (pad=pad@entry=0x7f3f900ff8f0 [GstPad], active=0) at gstpad.c:1079
        parent = 0x7f3f3004c1a0 [GstVaapiDecode]
        old = GST_PAD_MODE_PUSH
        ret = 0
        __func__ = "gst_pad_set_active"
        __PRETTY_FUNCTION__ = "gst_pad_set_active"
#5  0x00007f3fc61a4dbd in activate_pads (vpad=<optimized out>, ret=0x7ffda8991e90, active=0x7ffda8991edc) at gstelement.c:2736
        pad = 0x7f3f900ff8f0 [GstPad]
        cont = 1
#6  0x00007f3fc61b522c in gst_iterator_fold (it=it@entry=0x7f3f240a6010, func=func@entry=0x7f3fc61a4da0 <activate_pads>, ret=ret@entry=0x7ffda8991e90, user_data=user_data@entry=0x7ffda8991edc) at gstiterator.c:614
        item =
              {g_type = 23461424, data = {{v_int = -1878001424, v_uint = 2416965872, v_long = 139910976633072, v_ulong = 139910976633072, v_int64 = 139910976633072, v_uint64 = 139910976633072, v_float = -2.83935518e-29, v_double = 6.9125207030498272e-310, v_pointer = 0x7f3f900ff8f0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        result = GST_ITERATOR_OK
#7  0x00007f3fc61a521a in iterator_activate_fold_with_resync (iter=iter@entry=0x7f3f240a6010, user_data=user_data@entry=0x7ffda8991edc, func=0x7f3fc61a4da0 <activate_pads>) at gstelement.c:2760
        ires = <optimized out>
        ret =
              {g_type = 20, data = {{v_int = 1, v_uint = 1, v_long = 1, v_ulong = 1, v_int64 = 1, v_uint64 = 1, v_float = 1.40129846e-45, v_double = 4.9406564584124654e-324, v_pointer = 0x1}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
#8  0x00007f3fc61a703e in gst_element_pads_activate (element=element@entry=0x7f3f3004c1a0 [GstVaapiDecode], active=active@entry=0) at gstelement.c:2804
        iter = 0x7f3f240a6010
---Type <return> to continue, or q <return> to quit---
        res = 1
        __PRETTY_FUNCTION__ = "gst_element_pads_activate"
#9  0x00007f3fc61a72d6 in gst_element_change_state_func (element=0x7f3f3004c1a0 [GstVaapiDecode], transition=<optimized out>) at gstelement.c:2870
        l = <optimized out>
        state = GST_STATE_PAUSED
        next = GST_STATE_READY
        result = GST_STATE_CHANGE_SUCCESS
        __func__ = "gst_element_change_state_func"
        __PRETTY_FUNCTION__ = "gst_element_change_state_func"
#10 0x00007f3fc599e535 in gst_video_decoder_change_state (element=0x7f3f3004c1a0 [GstVaapiDecode], transition=GST_STATE_CHANGE_PAUSED_TO_READY)
    at gstvideodecoder.c:2459
        decoder = 0x7f3f3004c1a0 [GstVaapiDecode]
        decoder_class = 0x7f3f8c005850
        ret = <optimized out>
        __PRETTY_FUNCTION__ = "gst_video_decoder_change_state"
#11 0x00007f3fc61a91ce in gst_element_change_state (element=element@entry=0x7f3f3004c1a0 [GstVaapiDecode], transition=transition@entry=GST_STATE_CHANGE_PAUSED_TO_READY) at gstelement.c:2648
        oclass = 0x7f3f8c005850
        ret = GST_STATE_CHANGE_SUCCESS
        __PRETTY_FUNCTION__ = "gst_element_change_state"
#12 0x00007f3fc61a9947 in gst_element_set_state_func (element=0x7f3f3004c1a0 [GstVaapiDecode], state=GST_STATE_READY) at gstelement.c:2602
        current = GST_STATE_PAUSED
        next = <optimized out>
        old_pending = <optimized out>
        ret = <optimized out>
        transition = GST_STATE_CHANGE_PAUSED_TO_READY
        old_ret = <optimized out>
        __func__ = "gst_element_set_state_func"
        __PRETTY_FUNCTION__ = "gst_element_set_state_func"
#13 0x00007f3fc6188365 in gst_bin_change_state_func (next=GST_STATE_READY, current=GST_STATE_PAUSED, start_time=0, base_time=2803243898520, element=0x7f3f3004c1a0 [GstVaapiDecode], bin=0x7f3f2c0160d0 [GstVaapiDecodeBin]) at gstbin.c:2414
        child_current = <optimized out>
        found = <optimized out>
        ret = <optimized out>
        locked = <optimized out>
        child_pending = <optimized out>
        child = 0x7f3f3004c1a0 [GstVaapiDecode]
        bin = 0x7f3f2c0160d0 [GstVaapiDecodeBin]
        ret = <optimized out>
        current = GST_STATE_PAUSED
        next = GST_STATE_READY
        have_async = 0
        have_no_preroll = 0
        base_time = 2803243898520
        start_time = 0
---Type <return> to continue, or q <return> to quit---
        it = 0x7f3f4c096260
        done = 0
        data =
              {g_type = 25945344, data = {{v_int = 805618080, v_uint = 805618080, v_long = 139909365285280, v_ulong = 139909365285280, v_int64 = 139909365285280, v_uint64 = 139909365285280, v_float = 4.82964779e-10, v_double = 6.9124410918910742e-310, v_pointer = 0x7f3f3004c1a0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        __PRETTY_FUNCTION__ = "gst_bin_change_state_func"
        __func__ = "gst_bin_change_state_func"
#14 0x00007f3fc6188365 in gst_bin_change_state_func (element=0x7f3f2c0160d0 [GstVaapiDecodeBin], transition=GST_STATE_CHANGE_PAUSED_TO_READY) at gstbin.c:2756
        child = 0x7f3f3004c1a0 [GstVaapiDecode]
        bin = 0x7f3f2c0160d0 [GstVaapiDecodeBin]
        ret = <optimized out>
        current = GST_STATE_PAUSED
        next = GST_STATE_READY
        have_async = 0
        have_no_preroll = 0
        base_time = 2803243898520
        start_time = 0
        it = 0x7f3f4c096260
        done = 0
        data =
              {g_type = 25945344, data = {{v_int = 805618080, v_uint = 805618080, v_long = 139909365285280, v_ulong = 139909365285280, v_int64 = 139909365285280, v_uint64 = 139909365285280, v_float = 4.82964779e-10, v_double = 6.9124410918910742e-310, v_pointer = 0x7f3f3004c1a0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        __PRETTY_FUNCTION__ = "gst_bin_change_state_func"
        __func__ = "gst_bin_change_state_func"
#15 0x00007f3f40464a41 in  () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so
#16 0x00007f3fc61a91ce in gst_element_change_state (element=element@entry=0x7f3f2c0160d0 [GstVaapiDecodeBin], transition=transition@entry=GST_STATE_CHANGE_PAUSED_TO_READY) at gstelement.c:2648
        oclass = 0x7f3f8c041c90
        ret = GST_STATE_CHANGE_SUCCESS
        __PRETTY_FUNCTION__ = "gst_element_change_state"
#17 0x00007f3fc61a9947 in gst_element_set_state_func (element=0x7f3f2c0160d0 [GstVaapiDecodeBin], state=GST_STATE_READY) at gstelement.c:2602
        current = GST_STATE_PAUSED
        next = <optimized out>
        old_pending = <optimized out>
        ret = <optimized out>
        transition = GST_STATE_CHANGE_PAUSED_TO_READY
        old_ret = <optimized out>
        __func__ = "gst_element_set_state_func"
        __PRETTY_FUNCTION__ = "gst_element_set_state_func"
#18 0x00007f3fc6188365 in gst_bin_change_state_func (next=GST_STATE_READY, current=GST_STATE_PAUSED, start_time=0, base_time=2803243898520, element=0x7f3f2c0160d0 [GstVaapiDecodeBin], bin=0x1ac4bc0 [GstDecodeBin]) at gstbin.c:2414
        child_current = <optimized out>
        found = <optimized out>
---Type <return> to continue, or q <return> to quit---
        ret = <optimized out>
        locked = <optimized out>
        child_pending = <optimized out>
        child = 0x7f3f2c0160d0 [GstVaapiDecodeBin]
        bin = 0x1ac4bc0 [GstDecodeBin]
        ret = <optimized out>
        current = GST_STATE_PAUSED
        next = GST_STATE_READY
        have_async = 0
        have_no_preroll = 0
        base_time = 2803243898520
        start_time = 0
        it = 0x7f3f44012bd0
        done = 0
        data =
              {g_type = 25945344, data = {{v_int = 738287824, v_uint = 738287824, v_long = 139909297955024, v_ulong = 139909297955024, v_int64 = 139909297955024, v_uint64 = 139909297955024, v_float = 1.83857443e-12, v_double = 6.9124377653344327e-310, v_pointer = 0x7f3f2c0160d0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        __PRETTY_FUNCTION__ = "gst_bin_change_state_func"
        __func__ = "gst_bin_change_state_func"
#19 0x00007f3fc6188365 in gst_bin_change_state_func (element=0x1ac4bc0 [GstDecodeBin], transition=GST_STATE_CHANGE_PAUSED_TO_READY) at gstbin.c:2756
        child = 0x7f3f2c0160d0 [GstVaapiDecodeBin]
        bin = 0x1ac4bc0 [GstDecodeBin]
        ret = <optimized out>
        current = GST_STATE_PAUSED
        next = GST_STATE_READY
        have_async = 0
        have_no_preroll = 0
        base_time = 2803243898520
        start_time = 0
        it = 0x7f3f44012bd0
        done = 0
        data =
              {g_type = 25945344, data = {{v_int = 738287824, v_uint = 738287824, v_long = 139909297955024, v_ulong = 139909297955024, v_int64 = 139909297955024, v_uint64 = 139909297955024, v_float = 1.83857443e-12, v_double = 6.9124377653344327e-310, v_pointer = 0x7f3f2c0160d0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        __PRETTY_FUNCTION__ = "gst_bin_change_state_func"
        __func__ = "gst_bin_change_state_func"
#20 0x00007f3fb80a7e57 in gst_decode_bin_change_state (element=0x1ac4bc0 [GstDecodeBin], transition=GST_STATE_CHANGE_PAUSED_TO_READY) at gstdecodebin2.c:5296
        bret = <optimized out>
        ret = GST_STATE_CHANGE_SUCCESS
        dbin = 0x1ac4bc0 [GstDecodeBin]
        chain_to_free = 0x0
        __PRETTY_FUNCTION__ = "gst_decode_bin_change_state"
#21 0x00007f3fc61a91ce in gst_element_change_state (element=element@entry=0x1ac4bc0 [GstDecodeBin], transition=transition@entry=GST_STATE_CHANGE_PAUSED_TO_READY)
---Type <return> to continue, or q <return> to quit---
    at gstelement.c:2648
        oclass = 0x1abf420
        ret = GST_STATE_CHANGE_SUCCESS
        __PRETTY_FUNCTION__ = "gst_element_change_state"
#22 0x00007f3fc61a9947 in gst_element_set_state_func (element=0x1ac4bc0 [GstDecodeBin], state=GST_STATE_READY) at gstelement.c:2602
        current = GST_STATE_PAUSED
        next = <optimized out>
        old_pending = <optimized out>
        ret = <optimized out>
        transition = GST_STATE_CHANGE_PAUSED_TO_READY
        old_ret = <optimized out>
        __func__ = "gst_element_set_state_func"
        __PRETTY_FUNCTION__ = "gst_element_set_state_func"
#23 0x00007f3fc6188365 in gst_bin_change_state_func (next=GST_STATE_READY, current=GST_STATE_PAUSED, start_time=0, base_time=2803243898520, element=0x1ac4bc0 [GstDecodeBin], bin=0x7f3f9c018a50 [GstPipeline]) at gstbin.c:2414
        child_current = <optimized out>
        found = <optimized out>
        ret = <optimized out>
        locked = <optimized out>
        child_pending = <optimized out>
        child = 0x1ac4bc0 [GstDecodeBin]
        bin = 0x7f3f9c018a50 [GstPipeline]
        ret = <optimized out>
        current = GST_STATE_PAUSED
        next = GST_STATE_READY
        have_async = 0
        have_no_preroll = 0
        base_time = 2803243898520
        start_time = 0
        it = 0x7f3f44012ed0
        done = 0
        data =
              {g_type = 25945344, data = {{v_int = 28068800, v_uint = 28068800, v_long = 28068800, v_ulong = 28068800, v_int64 = 28068800, v_uint64 = 28068800, v_float = 6.32915173e-38, v_double = 1.3867829799988781e-316, v_pointer = 0x1ac4bc0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        __PRETTY_FUNCTION__ = "gst_bin_change_state_func"
        __func__ = "gst_bin_change_state_func"
#24 0x00007f3fc6188365 in gst_bin_change_state_func (element=0x7f3f9c018a50 [GstPipeline], transition=GST_STATE_CHANGE_PAUSED_TO_READY) at gstbin.c:2756
        child = 0x1ac4bc0 [GstDecodeBin]
        bin = 0x7f3f9c018a50 [GstPipeline]
        ret = <optimized out>
        current = GST_STATE_PAUSED
        next = GST_STATE_READY
        have_async = 0
        have_no_preroll = 0
---Type <return> to continue, or q <return> to quit---
        base_time = 2803243898520
        start_time = 0
        it = 0x7f3f44012ed0
        done = 0
        data =
              {g_type = 25945344, data = {{v_int = 28068800, v_uint = 28068800, v_long = 28068800, v_ulong = 28068800, v_int64 = 28068800, v_uint64 = 28068800, v_float = 6.32915173e-38, v_double = 1.3867829799988781e-316, v_pointer = 0x1ac4bc0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        __PRETTY_FUNCTION__ = "gst_bin_change_state_func"
        __func__ = "gst_bin_change_state_func"
#25 0x00007f3fc61a91ce in gst_element_change_state (element=element@entry=0x7f3f9c018a50 [GstPipeline], transition=transition@entry=GST_STATE_CHANGE_PAUSED_TO_READY) at gstelement.c:2648
        oclass = 0x18d9800
        ret = GST_STATE_CHANGE_SUCCESS
        __PRETTY_FUNCTION__ = "gst_element_change_state"
#26 0x00007f3fc61a9947 in gst_element_set_state_func (element=0x7f3f9c018a50 [GstPipeline], state=GST_STATE_NULL) at gstelement.c:2602
        current = GST_STATE_PAUSED
        next = <optimized out>
        old_pending = <optimized out>
        ret = <optimized out>
        transition = GST_STATE_CHANGE_PAUSED_TO_READY
        old_ret = <optimized out>
        __func__ = "gst_element_set_state_func"
        __PRETTY_FUNCTION__ = "gst_element_set_state_func"
#27 0x0000000000948e3f in gst_media_object::changeState(GstState, bool) (this=0x22611a0, _state=GST_STATE_NULL, _verbose=true)

here's the bt of a qtdemux thread

#0  0x00007f3fc43898e9 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f3fc5c7abdf in g_cond_wait (cond=cond@entry=0x7f3f24049390, mutex=mutex@entry=0x7f3f24049368)
    at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread-posix.c:1394
        sampled = 5877
#2  0x00007f3fc3174b82 in gst_data_queue_push (queue=0x7f3f240493c0 [GstDataQueue], item=item@entry=0x7f3f4c0c4920) at gstdataqueue.c:520
        priv = 0x7f3f24049340
        __func__ = "gst_data_queue_push"
#3  0x00007f3fb05c6ab5 in gst_multi_queue_chain (pad=<optimized out>, parent=<optimized out>, buffer=0x2180bc0) at gstmultiqueue.c:1891
        sq = 0x7f3f780be0b0
        mq = 0x7f3f6c091230 [GstMultiQueue]
        item = 0x7f3f4c0c4920
        curid = <optimized out>
        timestamp = 16832000000
        duration = 21333333
        __PRETTY_FUNCTION__ = "gst_multi_queue_chain"
#4  0x00007f3fc61be59f in gst_pad_push_data (data=0x2180bc0, type=4112, pad=0x7f3f340436b0 [GstPad]) at gstpad.c:4188
        chainfunc = 0x7f3fb05c69c0 <gst_multi_queue_chain>
        parent = 0x7f3f6c091230 [GstMultiQueue]
        ret = <optimized out>
        handled = 0
        peer = 0x7f3f340436b0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#5  0x00007f3fc61be59f in gst_pad_push_data (pad=pad@entry=0x7f3f280234a0 [GstPad], type=type@entry=4112, data=data@entry=0x2180bc0) at gstpad.c:4440
        peer = 0x7f3f340436b0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#6  0x00007f3fc61c6543 in gst_pad_push (pad=0x7f3f280234a0 [GstPad], buffer=0x2180bc0) at gstpad.c:4559
        res = <optimized out>
        __func__ = "gst_pad_push"
#7  0x00007f3f881a27c7 in  () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstisomp4.so
#8  0x00007f3f881bbab7 in  () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstisomp4.so
#9  0x00007f3fc61f0f31 in gst_task_func (task=0x7f3f1c04e4d0 [GstTask]) at gsttask.c:332
        lock = 0x7f3f14013ba0
        tself = 0x7f3f28098770
        priv = 0x7f3f1c04e480
        __PRETTY_FUNCTION__ = "gst_task_func"
#10 0x00007f3fc5c5d54e in g_thread_pool_thread_proxy (data=<optimized out>) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthreadpool.c:307
        task = 0x7f3f3400aa50
        pool = 0x18c8e00
#11 0x00007f3fc5c5cbb5 in g_thread_proxy (data=0x7f3f28098770) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread.c:780
        thread = 0x7f3f28098770
#12 0x00007f3fc4efa6ba in start_thread (arg=0x7f3f03777700) at pthread_create.c:333
---Type <return> to continue, or q <return> to quit---
        __res = <optimized out>
        pd = 0x7f3f03777700
        now = <optimized out>
        unwind_buf =
              {cancel_jmp_buf = {{jmp_buf = {139908617828096, 4465231497355108243, 0, 139910103163487, 8388608, 139908761057232, -4356750446556307565, -4357169156185481325}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#13 0x00007f3fc438f82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

thats the bt of a multiqueue, probably for one of the pipelines:

#0  0x00007f3fc43898e9 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f3fc5c7abdf in g_cond_wait (cond=cond@entry=0x7f3f780be250, mutex=mutex@entry=0x7f3f6c0913a0)
    at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread-posix.c:1394
        sampled = 3558
#2  0x00007f3fb05c7b65 in gst_multi_queue_loop (pad=<optimized out>) at gstmultiqueue.c:1647
        sq = 0x7f3f780be0b0
        item = <optimized out>
        sitem = 0x7f3f4c0c4760
        mq = 0x7f3f6c091230 [GstMultiQueue]
        object = <optimized out>
        newid = 5532
        result = <optimized out>
        next_time = 16932666666
        is_buffer = 1
        do_update_buffering = 0
        dropping = 0
        __PRETTY_FUNCTION__ = "gst_multi_queue_loop"
#3  0x00007f3fc61f0f31 in gst_task_func (task=0x7f3f78022830 [GstTask]) at gsttask.c:332
        lock = 0x7f3f2c0c7740
        tself = 0x7f3f7000c720
        priv = 0x7f3f780227e0
        __PRETTY_FUNCTION__ = "gst_task_func"
#4  0x00007f3fc5c5d54e in g_thread_pool_thread_proxy (data=<optimized out>) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthreadpool.c:307
        task = 0x7f3f9000b430
        pool = 0x18c8e00
#5  0x00007f3fc5c5cbb5 in g_thread_proxy (data=0x7f3f7000c720) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread.c:780
        thread = 0x7f3f7000c720
#6  0x00007f3fc4efa6ba in start_thread (arg=0x7f3f20ebf700) at pthread_create.c:333
        __res = <optimized out>
        pd = 0x7f3f20ebf700
        now = <optimized out>
        unwind_buf =
              {cancel_jmp_buf = {{jmp_buf = {139909112002304, 4465231497355108243, 0, 139908886815327, 8388608, 139909500059584, -4356685407866544237, -4357169156185481325}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#7  0x00007f3fc438f82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109


here's the bt for the other multiqueue: this is also the thread which owns the mutex i'm waiting for in the main thread. this thread waits for a gmutex i can't futher investigate. any hints?

#0  0x00007f3fc43898e9 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f3fc5c7abdf in g_cond_wait (cond=0x7f3f3004c630, mutex=0x7f3f3004c628) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread-posix.c:1394
        sampled = 1913
#2  0x00007f3f4045981b in  () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so
#3  0x00007f3fc59994c6 in gst_video_decoder_decode_frame (decoder=decoder@entry=0x7f3f3004c1a0 [GstVaapiDecode], frame=0x7f3fac029720) at gstvideodecoder.c:3329
        priv = 0x7f3f3004c000
        decoder_class = 0x7f3f8c005850
        ret = GST_FLOW_OK
        __func__ = "gst_video_decoder_decode_frame"
        __PRETTY_FUNCTION__ = "gst_video_decoder_decode_frame"
#4  0x00007f3fc59a168c in gst_video_decoder_have_frame (decoder=0x7f3f3004c1a0 [GstVaapiDecode]) at gstvideodecoder.c:3261
        priv = 0x7f3f3004c000
        buffer = 0x7f3f4c0a56c0
        n_available = <optimized out>
        pts = <optimized out>
        dts = <optimized out>
        duration = <optimized out>
        ret = GST_FLOW_OK
        __PRETTY_FUNCTION__ = "gst_video_decoder_have_frame"
#5  0x00007f3f4045868a in  () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so
#6  0x00007f3fc5999816 in gst_video_decoder_parse_available (dec=dec@entry=0x7f3f3004c1a0 [GstVaapiDecode], at_eos=at_eos@entry=0, new_buffer=0,
    new_buffer@entry=1) at gstvideodecoder.c:894
        decoder_class = 0x7f3f8c005850
        priv = 0x7f3f3004c000
        ret = GST_FLOW_OK
        was_available = 26395
        available = 26395
        inactive = 0
        __PRETTY_FUNCTION__ = "gst_video_decoder_parse_available"
#7  0x00007f3fc59999c4 in gst_video_decoder_chain_forward (decoder=decoder@entry=0x7f3f3004c1a0 [GstVaapiDecode], buf=buf@entry=0x7f3f2407fe50, at_eos=at_eos@entry=0) at gstvideodecoder.c:2117
        priv = 0x7f3f3004c000
        klass = <optimized out>
        ret = GST_FLOW_OK
        __func__ = "gst_video_decoder_chain_forward"
#8  0x00007f3fc599c173 in gst_video_decoder_chain (pad=<optimized out>, parent=0x7f3f3004c1a0 [GstVaapiDecode], buf=0x7f3f2407fe50) at gstvideodecoder.c:2413
        decoder = 0x7f3f3004c1a0 [GstVaapiDecode]
        ret = GST_FLOW_OK
        __PRETTY_FUNCTION__ = "gst_video_decoder_chain"
#9  0x00007f3fc61be59f in gst_pad_push_data (data=0x7f3f2407fe50, type=4112, pad=0x7f3f900ff8f0 [GstPad]) at gstpad.c:4188
        chainfunc = 0x7f3fc599be80 <gst_video_decoder_chain>
        parent = 0x7f3f3004c1a0 [GstVaapiDecode]
        ret = <optimized out>
        handled = 0
        peer = 0x7f3f900ff8f0 [GstPad]
---Type <return> to continue, or q <return> to quit---
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#10 0x00007f3fc61be59f in gst_pad_push_data (pad=pad@entry=0x7f3f8c02a2a0 [GstProxyPad], type=type@entry=4112, data=data@entry=0x7f3f2407fe50) at gstpad.c:4440
        peer = 0x7f3f900ff8f0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#11 0x00007f3fc61c6543 in gst_pad_push (pad=pad@entry=0x7f3f8c02a2a0 [GstProxyPad], buffer=buffer@entry=0x7f3f2407fe50) at gstpad.c:4559
        res = <optimized out>
        __func__ = "gst_pad_push"
#12 0x00007f3fc61af563 in gst_proxy_pad_chain_default (pad=0x7f3f8c046c80 [GstGhostPad], parent=<optimized out>, buffer=0x7f3f2407fe50) at gstghostpad.c:126
        res = <optimized out>
        internal = 0x7f3f8c02a2a0 [GstProxyPad]
        __func__ = "gst_proxy_pad_chain_default"
#13 0x00007f3fc61be59f in gst_pad_push_data (data=0x7f3f2407fe50, type=4112, pad=0x7f3f8c046c80 [GstGhostPad]) at gstpad.c:4188
        chainfunc = 0x7f3fc61af4b0 <gst_proxy_pad_chain_default>
        parent = 0x7f3f2c0160d0 [GstVaapiDecodeBin]
        ret = <optimized out>
        handled = 0
        peer = 0x7f3f8c046c80 [GstGhostPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#14 0x00007f3fc61be59f in gst_pad_push_data (pad=pad@entry=0x7f3fac07cde0 [GstPad], type=type@entry=4112, data=data@entry=0x7f3f2407fe50) at gstpad.c:4440
        peer = 0x7f3f8c046c80 [GstGhostPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#15 0x00007f3fc61c6543 in gst_pad_push (pad=0x7f3fac07cde0 [GstPad], buffer=0x7f3f2407fe50) at gstpad.c:4559
        res = <optimized out>
        __func__ = "gst_pad_push"
#16 0x00007f3fc316452d in gst_base_transform_chain (pad=<optimized out>, parent=0x7f3f1800c2d0 [GstCapsFilter], buffer=<optimized out>)
    at gstbasetransform.c:2369
        position_out = <optimized out>
        trans = 0x7f3f1800c2d0 [GstCapsFilter]
        klass = 0x7f3f9c007640
        priv = 0x7f3f1800c200
        ret = <optimized out>
        position = 16880000000
        timestamp = <optimized out>
        duration = <optimized out>
        outbuf = 0x7f3f2407fe50
        __PRETTY_FUNCTION__ = "gst_base_transform_chain"
#17 0x00007f3fc61be59f in gst_pad_push_data (data=0x7f3f2407fe50, type=4112, pad=0x22dc2a0 [GstPad]) at gstpad.c:4188
---Type <return> to continue, or q <return> to quit---
        chainfunc = 0x7f3fc31643a0 <gst_base_transform_chain>
        parent = 0x7f3f1800c2d0 [GstCapsFilter]
        ret = <optimized out>
        handled = 0
        peer = 0x22dc2a0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#18 0x00007f3fc61be59f in gst_pad_push_data (pad=pad@entry=0x7f3f6c0aa2a0 [GstPad], type=type@entry=4112, data=data@entry=0x7f3f2407fe50) at gstpad.c:4440
        peer = 0x22dc2a0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#19 0x00007f3fc61c6543 in gst_pad_push (pad=0x7f3f6c0aa2a0 [GstPad], buffer=buffer@entry=0x7f3f2407fe50) at gstpad.c:4559
        res = <optimized out>
        __func__ = "gst_pad_push"
#20 0x00007f3fc3148099 in gst_base_parse_push_frame (parse=parse@entry=0x7f3f78099260 [GstH264Parse], frame=frame@entry=0x7f3f34021e80) at gstbaseparse.c:2533
        ret = GST_FLOW_OK
        last_start = <optimized out>
        last_stop = 16880000000
        klass = <optimized out>
        buffer = 0x7f3f2407fe50
        size = <optimized out>
        __func__ = "gst_base_parse_push_frame"
        __PRETTY_FUNCTION__ = "gst_base_parse_push_frame"
#21 0x00007f3fc314bf8f in gst_base_parse_finish_frame (frame=0x7f3f34021e80, parse=0x7f3f78099260 [GstH264Parse]) at gstbaseparse.c:2352
        offset = <optimized out>
        buffer = 0x7f3f2407fe50
        __func__ = "gst_base_parse_finish_frame"
        __PRETTY_FUNCTION__ = "gst_base_parse_finish_frame"
#22 0x00007f3fc314bf8f in gst_base_parse_finish_frame (parse=parse@entry=0x7f3f78099260 [GstH264Parse], frame=frame@entry=0x7f3f34021e80, size=<optimized out>)
    at gstbaseparse.c:2691
        __func__ = "gst_base_parse_finish_frame"
        __PRETTY_FUNCTION__ = "gst_base_parse_finish_frame"
#23 0x00007f3fb016604f in gst_h264_parse_handle_frame (frame=0x7f3f34021e80, parse=0x7f3f78099260 [GstH264Parse]) at gsth264parse.c:1021
        h264parse = 0x7f3f78099260 [GstH264Parse]
        buffer = <optimized out>
        ret = <optimized out>
        nalu =
              {ref_idc = 0, type = 0, idr_pic_flag = 0 '\000', size = 0, offset = 0, sc_offset = 0, valid = 0, data = 0x0, header_bytes = 0 '\000', extension_type = 0 '\000', extension = {mvc = {non_idr_flag = 0 '\000', priority_id = 0 '\000', view_id = 0, temporal_id = 0 '\000', anchor_pic_flag = 0 '\000', inter_view_flag = 0 '\000'}}}
        nl = <optimized out>
        parse_res = GST_H264_PARSER_ERROR
        map =
---Type <return> to continue, or q <return> to quit---
            {memory = 0x7f3f78032000, flags = GST_MAP_READ, data = 0x7f3f78032090 "", size = 26395, maxsize = 26402, user_data = {0x671b, 0x0, 0x7f3f78099260, 0x48}, _gst_reserved = {0x7f3fc64784b0 <_gst_debug_min>, 0x7f3f137fec0c, 0x7f3f2407fa10, 0x0}}
        left = 26395
        h264parse = 0x7f3f78099260 [GstH264Parse]
        buffer = <optimized out>
        map =
            {memory = 0x7f3f78032000, flags = GST_MAP_READ, data = 0x7f3f78032090 "", size = 26395, maxsize = 26402, user_data = {0x671b, 0x0, 0x7f3f78099260, 0x48}, _gst_reserved = {0x7f3fc64784b0 <_gst_debug_min>, 0x7f3f137fec0c, 0x7f3f2407fa10, 0x0}}
        data = <optimized out>
        size = <optimized out>
        current_off = 0
        drain = <optimized out>
        nonext = <optimized out>
        nalparser = <optimized out>
        nalu =
              {ref_idc = 0, type = 0, idr_pic_flag = 0 '\000', size = 0, offset = 0, sc_offset = 80000000, valid = 0, data = 0xdfd0c0c00 <error: Cannot access memory at address 0xdfd0c0c00>, header_bytes = 0 '\000', extension_type = 0 '\000', extension = {mvc = {non_idr_flag = 0 '\000', priority_id = 0 '\000', view_id = 0, temporal_id = 0 '\000', anchor_pic_flag = 0 '\000', inter_view_flag = 0 '\000'}}}
        pres = <optimized out>
        framesize = <optimized out>
        __func__ = "gst_h264_parse_handle_frame"
#24 0x00007f3fb016604f in gst_h264_parse_handle_frame (parse=0x7f3f78099260 [GstH264Parse], frame=0x7f3f34021e80, skipsize=<optimized out>)
    at gsth264parse.c:1065
        h264parse = 0x7f3f78099260 [GstH264Parse]
        buffer = <optimized out>
        map =
            {memory = 0x7f3f78032000, flags = GST_MAP_READ, data = 0x7f3f78032090 "", size = 26395, maxsize = 26402, user_data = {0x671b, 0x0, 0x7f3f78099260, 0x48}, _gst_reserved = {0x7f3fc64784b0 <_gst_debug_min>, 0x7f3f137fec0c, 0x7f3f2407fa10, 0x0}}
        data = <optimized out>
        size = <optimized out>
        current_off = 0
        drain = <optimized out>
        nonext = <optimized out>
        nalparser = <optimized out>
        nalu =
              {ref_idc = 0, type = 0, idr_pic_flag = 0 '\000', size = 0, offset = 0, sc_offset = 80000000, valid = 0, data = 0xdfd0c0c00 <error: Cannot access memory at address 0xdfd0c0c00>, header_bytes = 0 '\000', extension_type = 0 '\000', extension = {mvc = {non_idr_flag = 0 '\000', priority_id = 0 '\000', view_id = 0, temporal_id = 0 '\000', anchor_pic_flag = 0 '\000', inter_view_flag = 0 '\000'}}}
        pres = <optimized out>
        framesize = <optimized out>
        __func__ = "gst_h264_parse_handle_frame"
#25 0x00007f3fc31444b0 in gst_base_parse_handle_buffer (parse=parse@entry=0x7f3f78099260 [GstH264Parse], buffer=<optimized out>, skip=skip@entry=0x7f3f137fec08, flushed=flushed@entry=0x7f3f137fec0c) at gstbaseparse.c:2166
        klass = 0x7f3f9c039000
        frame = 0x7f3f34021e80
---Type <return> to continue, or q <return> to quit---
        ret = <optimized out>
        __func__ = "gst_base_parse_handle_buffer"
        __PRETTY_FUNCTION__ = "gst_base_parse_handle_buffer"
#26 0x00007f3fc3148dae in gst_base_parse_chain (pad=<optimized out>, parent=0x7f3f78099260 [GstH264Parse], buffer=<optimized out>) at gstbaseparse.c:3230
        flush = 0
        updated_prev_pts = <optimized out>
        bclass = <optimized out>
        parse = 0x7f3f78099260 [GstH264Parse]
        ret = GST_FLOW_OK
        old_ret = GST_FLOW_OK
        tmpbuf = <optimized out>
        skip = 0
        min_size = <optimized out>
        av = 26395
        pts = 16840000000
        dts = <optimized out>
        __PRETTY_FUNCTION__ = "gst_base_parse_chain"
#27 0x00007f3fc61be59f in gst_pad_push_data (data=0x7f3f4c0a56c0, type=4112, pad=0x22dd4a0 [GstPad]) at gstpad.c:4188
        chainfunc = 0x7f3fc3148620 <gst_base_parse_chain>
        parent = 0x7f3f78099260 [GstH264Parse]
        ret = <optimized out>
        handled = 0
        peer = 0x22dd4a0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#28 0x00007f3fc61be59f in gst_pad_push_data (pad=pad@entry=0x22dc720 [GstPad], type=type@entry=4112, data=data@entry=0x7f3f4c0a56c0) at gstpad.c:4440
        peer = 0x22dd4a0 [GstPad]
        ret = <optimized out>
        handled = 0
        __PRETTY_FUNCTION__ = "gst_pad_push_data"
#29 0x00007f3fc61c6543 in gst_pad_push (pad=0x22dc720 [GstPad], buffer=buffer@entry=0x7f3f4c0a56c0) at gstpad.c:4559
        res = <optimized out>
        __func__ = "gst_pad_push"
#30 0x00007f3fb05c8124 in gst_multi_queue_loop (allow_drop=<synthetic pointer>, object=0x7f3f4c0a56c0, sq=0x7f3f780a7170, mq=0x7f3f6c091230 [GstMultiQueue])
    at gstmultiqueue.c:1417
        buffer = 0x7f3f4c0a56c0
        timestamp = 16800000000
        duration = <optimized out>
        result = GST_FLOW_OK
        sq = 0x7f3f780a7170
        item = <optimized out>
        sitem = 0x7f3f4c0dad50
        mq = 0x7f3f6c091230 [GstMultiQueue]
        object = <optimized out>
---Type <return> to continue, or q <return> to quit---
        newid = 5534
        result = <optimized out>
        next_time = <optimized out>
        is_buffer = 1
        do_update_buffering = 0
        dropping = 0
        __PRETTY_FUNCTION__ = "gst_multi_queue_loop"
#31 0x00007f3fb05c8124 in gst_multi_queue_loop (pad=<optimized out>) at gstmultiqueue.c:1701
        sq = 0x7f3f780a7170
        item = <optimized out>
        sitem = 0x7f3f4c0dad50
        mq = 0x7f3f6c091230 [GstMultiQueue]
        object = <optimized out>
        newid = 5534
        result = <optimized out>
        next_time = <optimized out>
        is_buffer = 1
        do_update_buffering = 0
        dropping = 0
        __PRETTY_FUNCTION__ = "gst_multi_queue_loop"
#32 0x00007f3fc61f0f31 in gst_task_func (task=0x1adaef0 [GstTask]) at gsttask.c:332
        lock = 0x22dc790
        tself = 0x7f3f34026230
        priv = 0x1adaea0
        __PRETTY_FUNCTION__ = "gst_task_func"
#33 0x00007f3fc5c5d54e in g_thread_pool_thread_proxy (data=<optimized out>) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthreadpool.c:307
        task = 0x1abefb0
        pool = 0x18c8e00
#34 0x00007f3fc5c5cbb5 in g_thread_proxy (data=0x7f3f34026230) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread.c:780
        thread = 0x7f3f34026230
#35 0x00007f3fc4efa6ba in start_thread (arg=0x7f3f137ff700) at pthread_create.c:333
        __res = <optimized out>
        pd = 0x7f3f137ff700
        now = <optimized out>
        unwind_buf =
              {cancel_jmp_buf = {{jmp_buf = {139908886820608, 4465231497355108243, 0, 139908861633119, 8388608, 139910774439568, -4356785566503886957, -4357169156185481325}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#36 0x00007f3fc438f82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

the last thread is runned by a typefind:sink element:

#0  0x00007f3fc43898e9 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007f3fc5c7abdf in g_cond_wait (cond=cond@entry=0x7f3f1c04e0b0, mutex=mutex@entry=0x7f3f1c04e068)
    at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread-posix.c:1394
        sampled = 1
#2  0x00007f3fc61f10cd in gst_task_func (task=0x7f3f1c04e050 [GstTask]) at gsttask.c:317
        lock = 0x7f3f9c0ce550
        tself = 0x7f3f7409a0f0
        priv = 0x7f3f1c04e000
        __PRETTY_FUNCTION__ = "gst_task_func"
#3  0x00007f3fc5c5d54e in g_thread_pool_thread_proxy (data=<optimized out>) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthreadpool.c:307
        task = 0x7f3f7c0054b0
        pool = 0x18c8e00
#4  0x00007f3fc5c5cbb5 in g_thread_proxy (data=0x7f3f7409a0f0) at /build/glib2.0-prJhLS/glib2.0-2.48.2/./glib/gthread.c:780
        thread = 0x7f3f7409a0f0
#5  0x00007f3fc4efa6ba in start_thread (arg=0x7f3f02376700) at pthread_create.c:333
        __res = <optimized out>
        pd = 0x7f3f02376700
        now = <optimized out>
        unwind_buf =
              {cancel_jmp_buf = {{jmp_buf = {139908596852480, 4465231497355108243, 0, 139908634608223, 8388608, 139909365050352, -4356753195872247917, -4357169156185481325}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#6  0x00007f3fc438f82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

anyone has any idea on which this happens?

kind regards,
henning
Reply | Threaded
Open this post in threaded view
|

Re: gst_element_set_state deadlock

Sebastian Dröge-3
On Mon, 2017-04-03 at 02:01 -0700, tobatrance wrote:

> hi.
>
> i'm using ubuntu 16.04 and gstreamer 1.8.3. i'm using the pipeline filesrc
> -> decodebin -> appsink. i'm creating and destroying  multiple of these
> pipelines within short time and playing different videos concurrently.
> before destroying the pipeline I pause them and afterwards set them to
> GST_STATE_NULL. somewhen it happens that gst_element_set_state(pipeline,
> GST_STATE_NULL) does not return. in this log i'm running two 4k videos.
> first comes the backtrace of the mainloop thread. the mutex in frame 1 is a
> p_thread_mutex.
The backtrace is a bit hard to read in the mail (better attach as a
text file in the future), but the problem looks like you're setting the
state from (one of) the streaming threads. This is generally not
possible and you have to do it from another thread.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gst_element_set_state deadlock

tobatrance
Hi Sebastian.

thanks for your reply and sorry for this visual noise. I can assure you that I'm calling the state change from the main thread. I did a workaround which creates another thread and sets the state to null from this thread. This is not very nice but solves the problem for so far.
Reply | Threaded
Open this post in threaded view
|

Re: gst_element_set_state deadlock

matschne
Hey,

I think I've observed a deadlock in gst_element_set_state() when using the appsink element, too. My application freezes in a random interval when I want to change the state of a pipeline (from PLAYING to PAUSE or to NULL). Depending on the input data, it happens once per week or every hour.

In my application, I have a bunch of "input" pipelines (filesrc, rtmpsrc, rtspsrc) with a decodebin and a appsink:

i.e.
gst-launch-1.0 rtspsrc location=<URL> do-timestamp=true buffer-mode=2 protocols=0x00000004 latency=20000 ! rtph264depay ! h264parse  !  decodebin ! videorate ! videoscale ! videoconvert ! watchdog timeout=120000 ! appsink name=sink01 emit-signals=false async=false sync=true max-buffers=3 drop=true

And there is a "output" pipeline running (I know about the concat element and the input-selector element but they do not fit my needs), feeded by a thread. It is reading samples from appsink and push them to appsrc. Here is what the code looks like:

GstSample* sample = NULL;
sample = gst_app_sink_try_pull_sample(GST_APP_SINK(source_sink), TIME_MILLIS_TO_NANO(1000));
if (!sample) {
        LOG("DEBUG: Smells like EOS or trouble");
} else {
        buffer_sink = gst_sample_get_buffer (sample);
        buffer_src = gst_buffer_copy (buffer_sink);
        gst_sample_unref (sample);
        ret = gst_app_src_push_buffer(my_appsrc, buffer_src);
        if ( GST_FLOW_OK != ret) {
          LOG("DEBUG: Could not send sample to my_appsrc");
        }
}

After Sebastians hint I checked my source carefully - I definitely never change the state of any pipeline outside of the GMainLoop. I ran my application with GST_DEBUG=appsink:5 and GST_DEBUG_FILE=/tmp/appsink.txt. Here is what it looks like for a "frozen" pipeline:

2:54:22.654784974     1      0x204d9e0 DEBUG                appsink gstappsink.c:769:dequeue_buffer:<source_sink02> dequeued buffer 0x7f15104e4070
2:54:22.654789009     1      0x204d9e0 DEBUG                appsink gstappsink.c:1458:gst_app_sink_try_pull_sample:<source_sink02> we have a buffer 0x7f15104e4070
2:54:22.655399809     1      0x204d9e0 DEBUG                appsink gstappsink.c:1438:gst_app_sink_try_pull_sample:<source_sink02> trying to grab a buffer
2:54:22.655407127     1      0x204d9e0 DEBUG                appsink gstappsink.c:1449:gst_app_sink_try_pull_sample:<source_sink02> waiting for a buffer
2:54:22.694992808     1 0x7f139171dad0 DEBUG                appsink gstappsink.c:823:gst_app_sink_render:<source_sink02> pushing render buffer 0x7f156072bc90 on queue (0)
2:54:22.695030498     1      0x204d9e0 DEBUG                appsink gstappsink.c:1438:gst_app_sink_try_pull_sample:<source_sink02> trying to grab a buffer
2:54:22.695036295     1      0x204d9e0 DEBUG                appsink gstappsink.c:769:dequeue_buffer:<source_sink02> dequeued buffer 0x7f156072bc90
2:54:22.695040547     1      0x204d9e0 DEBUG                appsink gstappsink.c:1458:gst_app_sink_try_pull_sample:<source_sink02> we have a buffer 0x7f156072bc90
2:54:22.734320447     1 0x7f139171dad0 DEBUG                appsink gstappsink.c:823:gst_app_sink_render:<source_sink02> pushing render buffer 0x7f13b5b9b110 on queue (0)
2:54:22.734368013     1 0x7f139171dad0 DEBUG                appsink gstappsink.c:675:gst_app_sink_event:<source_sink02> receiving EOS
2:54:22.801331617     1      0x2053e30 DEBUG                appsink gstappsink.c:564:gst_app_sink_unlock_start:<source_sink02> unlock start

---> BAM! Deadlock!

Here is a example without a deadlock:
2:53:37.664156013     1      0x204dad0 DEBUG       appsink gstappsink.c:1438:gst_app_sink_try_pull_sample:<source_sink01> trying to grab a buffer
2:53:37.664175322     1      0x204dad0 DEBUG                appsink gstappsink.c:769:dequeue_buffer:<source_sink01> dequeued buffer 0x7f154884fb20
2:53:37.664180376     1      0x204dad0 DEBUG                appsink gstappsink.c:1458:gst_app_sink_try_pull_sample:<source_sink01> we have a buffer 0x7f154884fb20
2:53:37.665945471     1      0x204dad0 DEBUG                appsink gstappsink.c:1438:gst_app_sink_try_pull_sample:<source_sink01> trying to grab a buffer
2:53:37.665975609     1      0x204dad0 DEBUG                appsink gstappsink.c:1449:gst_app_sink_try_pull_sample:<source_sink01> waiting for a buffer
2:53:37.704112246     1 0x7f1544004370 DEBUG                appsink gstappsink.c:823:gst_app_sink_render:<source_sink01> pushing render buffer 0x7f1560792630 on queue (0)
2:53:37.704148439     1 0x7f1544004370 DEBUG                appsink gstappsink.c:675:gst_app_sink_event:<source_sink01> receiving EOS
2:53:37.704158813     1      0x204dad0 DEBUG                appsink gstappsink.c:1438:gst_app_sink_try_pull_sample:<source_sink01> trying to grab a buffer
2:53:37.704171246     1      0x204dad0 DEBUG                appsink gstappsink.c:769:dequeue_buffer:<source_sink01> dequeued buffer 0x7f1560792630
2:53:37.704176664     1      0x204dad0 DEBUG                appsink gstappsink.c:1458:gst_app_sink_try_pull_sample:<source_sink01> we have a buffer 0x7f1560792630
2:53:37.704809989     1      0x204dad0 DEBUG                appsink gstappsink.c:1438:gst_app_sink_try_pull_sample:<source_sink01> trying to grab a buffer
2:53:37.704822144     1      0x204dad0 DEBUG                appsink gstappsink.c:1476:gst_app_sink_try_pull_sample:<source_sink01> we are EOS, return NULL
2:53:37.705236465     1      0x2053e30 DEBUG                appsink gstappsink.c:564:gst_app_sink_unlock_start:<source_sink01> unlock start
2:53:37.705249499     1      0x2053e30 DEBUG                appsink gstappsink.c:579:gst_app_sink_unlock_stop:<source_sink01> unlock stop

Could there be a race condition in appsink? Or did I use the appsink / appsrc in a forbidden way?


Mathias
tobatrance wrote
Hi Sebastian.

thanks for your reply and sorry for this visual noise. I can assure you that I'm calling the state change from the main thread. I did a workaround which creates another thread and sets the state to null from this thread. This is not very nice but solves the problem for so far.
tobatrance wrote
Hi Sebastian.

thanks for your reply and sorry for this visual noise. I can assure you that I'm calling the state change from the main thread. I did a workaround which creates another thread and sets the state to null from this thread. This is not very nice but solves the problem for so far.
Reply | Threaded
Open this post in threaded view
|

Re: gst_element_set_state deadlock

Andres Gonzalez
In reply to this post by tobatrance
I know this thread is a few months old but thought I would add to it.

I have a similar pipeline:   filesrc  ->  decodebin  .....  -> appsrc

gst_element_set_state() works fine while the file is playing. However, after I get an EOS callback from the appsrc, any subsequent call to gst_element_set_state() blocks and the thread is deadlocked. My start/stop routines that call gst_element_set_state() on the pipeline are indeed in an application thread and not a GStreamer thread.

not sure how to resolve this.

-Andres
Reply | Threaded
Open this post in threaded view
|

Re: gst_element_set_state deadlock

toots
Same here with 1.10.4. It seems to go away with 1.14.2. Details: Pilepine:
filesrc location="/tmp/gni/bla.mp4" ! decodebin name=d d. ! queue ! audioconvert ! audioresample ! appsink max-buffers=10 drop=false sync=false name="audio_sink" caps="audio/x-raw,format=S16LE,layout=interleaved,channels=2,rate=44100" d. ! queue ! videoconvert ! videoscale add-borders=true ! videorate ! appsink name="video_sink" drop=false sync=false max-buffers=10 caps="video/x-raw,format=RGBA,width=320,height=240,framerate=25/1,pixel-aspect-ratio=1/1
Backtrace with 1.10.4:
#2  0x00007f383471578c in gst_base_sink_change_state (element=0x7f37e8008eb0, transition=) at gstbasesink.c:5080
#3  0x00007f383512872e in gst_element_change_state (element=element@entry=0x7f37e8008eb0, transition=transition@entry=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstelement.c:2695
#4  0x00007f3835128e9f in gst_element_set_state_func (element=0x7f37e8008eb0, state=GST_STATE_PAUSED) at gstelement.c:2649
#5  0x00007f38351071ad in gst_bin_element_set_state (next=GST_STATE_PAUSED, current=GST_STATE_PLAYING, start_time=20269770500, base_time=230148100213858, element=0x7f37e8008eb0, bin=0x7f38041da320)
    at gstbin.c:2619
#6  gst_bin_change_state_func (element=0x7f38041da320, transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstbin.c:2961
#7  0x00007f383514c73a in gst_pipeline_change_state (element=0x7f38041da320, transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstpipeline.c:499
#8  0x00007f383512872e in gst_element_change_state (element=element@entry=0x7f38041da320, transition=transition@entry=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstelement.c:2695
#9  0x00007f3835128e9f in gst_element_set_state_func (element=0x7f38041da320, state=GST_STATE_NULL) at gstelement.c:2649


Sent from the GStreamer-devel mailing list archive at Nabble.com.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel