Deadlock on setting queue to NULL state in PAUSED pipeline

Andrey Utkin andrey.krieger.utkin at gmail.com
Sat Dec 21 00:31:55 PST 2013


What i do:
create a pipeline, e.g. fakesrc ! queue name=to_delete ! fakesink
set it to PLAYING state
set it to PAUSED state after a while
set the queue element to NULL state, as this is recommended before
gst_bin_remove() on it. This step deadlocks.

Should i file a bugreport?

Below i list the app output, backtraces and source.

 $ gdb ./gstreamer_test
GNU gdb (Gentoo 7.5.1 p2) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from
/home/krieger/work/employers/netsol/gstreamer_drop_elements/gstreamer_test...done.
(gdb) run "fakesrc ! queue name=to_delete ! fakesink"
Starting program:
/home/krieger/work/employers/netsol/gstreamer_drop_elements/gstreamer_test
"fakesrc ! queue name=to_delete ! fakesink"
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Now playing: fakesrc ! queue name=to_delete ! fakesink
[New Thread 0x7ffff5fb5700 (LWP 12920)]
[New Thread 0x7ffff57b4700 (LWP 12921)]
[New Thread 0x7ffff4fb3700 (LWP 12922)]
Going PAUSED
^C
Program received signal SIGINT, Interrupt.
0x00007ffff731e0a4 in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) thread apply all bt

Thread 4 (Thread 0x7ffff4fb3700 (LWP 12922)):
#0  0x00007ffff731b96e in pthread_cond_timedwait () from /lib64/libpthread.so.0
#1  0x00007ffff75d3b81 in g_cond_wait_until (cond=0x619938,
mutex=0x619930, end_time=1101572183028) at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread-posix.c:859
#2  0x00007ffff754e2ed in g_async_queue_pop_intern_unlocked
(queue=0x619930, wait=1, end_time=1101572183028)
    at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gasyncqueue.c:424
#3  0x00007ffff754e524 in g_async_queue_timeout_pop (queue=0x619930,
timeout=15000000) at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gasyncqueue.c:545
#4  0x00007ffff75af7cf in g_thread_pool_wait_for_new_pool () at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthreadpool.c:169
#5  0x00007ffff75afa93 in g_thread_pool_thread_proxy (data=0x6191f0)
at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthreadpool.c:366
#6  0x00007ffff75af3d3 in g_thread_proxy (data=0x7ffff0003680) at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread.c:798
#7  0x00007ffff7316da6 in start_thread () from /lib64/libpthread.so.0
#8  0x00007ffff704fabd in clone () from /lib64/libc.so.6

Thread 3 (Thread 0x7ffff57b4700 (LWP 12921)):
#0  0x00007ffff731b5ec in pthread_cond_wait () from /lib64/libpthread.so.0
#1  0x00007ffff75d3a35 in g_cond_wait (cond=0x793180, mutex=0x793178)
at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread-posix.c:750
#2  0x00007ffff5fdbea6 in gst_base_sink_wait_preroll (sink=0x793050)
at gstbasesink.c:2153
#3  0x00007ffff5fdc12e in gst_base_sink_do_preroll (sink=0x793050,
obj=0x7ffff0008270) at gstbasesink.c:2243
#4  0x00007ffff5fdcd06 in gst_base_sink_do_sync (basesink=0x793050,
obj=0x7ffff0008270, late=0x7ffff57b3b10, step_end=0x7ffff57b3b14) at
gstbasesink.c:2445
#5  0x00007ffff5fddd96 in gst_base_sink_chain_unlocked
(basesink=0x793050, obj=0x7ffff0008270, is_list=0, pad=<optimized
out>) at gstbasesink.c:3341
#6  0x00007ffff5fdf36c in gst_base_sink_chain_main (basesink=0x793050,
pad=<optimized out>, obj=0x7ffff0008270, is_list=<optimized out>) at
gstbasesink.c:3486
#7  0x00007ffff7b3f4da in gst_pad_chain_data_unchecked (pad=0x78e6c0,
type=<optimized out>, data=0x7ffff0008270) at gstpad.c:3725
#8  0x00007ffff7b3fd9b in gst_pad_push_data (pad=0x78e490, type=4112,
data=0x7ffff0008270) at gstpad.c:3958
#9  0x00007ffff6232635 in gst_queue_push_one (queue=0x790060) at gstqueue.c:1124
#10 gst_queue_loop (pad=<optimized out>) at gstqueue.c:1253
#11 0x00007ffff7b6d9ff in gst_task_func (task=0x797000) at gsttask.c:316
#12 0x00007ffff75af9be in g_thread_pool_thread_proxy (data=0x61a6d0)
at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthreadpool.c:309
#13 0x00007ffff75af3d3 in g_thread_proxy (data=0x792e80) at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread.c:798
#14 0x00007ffff7316da6 in start_thread () from /lib64/libpthread.so.0
#15 0x00007ffff704fabd in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7ffff5fb5700 (LWP 12920)):
#0  0x00007ffff731b5ec in pthread_cond_wait () from /lib64/libpthread.so.0
#1  0x00007ffff75d3a35 in g_cond_wait (cond=0x797180, mutex=0x797138)
at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread-posix.c:750
#2  0x00007ffff7b6db90 in gst_task_func (task=0x797120) at gsttask.c:301
#3  0x00007ffff75af9be in g_thread_pool_thread_proxy (data=0x61a6d0)
at /var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthreadpool.c:309
#4  0x00007ffff75af3d3 in g_thread_proxy (data=0x792e30) at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread.c:798
#5  0x00007ffff7316da6 in start_thread () from /lib64/libpthread.so.0
#6  0x00007ffff704fabd in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7ffff7fc6700 (LWP 12916)):
#0  0x00007ffff731e0a4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007ffff73195cf in _L_lock_543 () from /lib64/libpthread.so.0
#2  0x00007ffff731942b in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00007ffff75d3650 in g_rec_mutex_lock (mutex=0x78e500) at
/var/tmp/portage/dev-libs/glib-2.36.4-r1/work/glib-2.36.4/glib/gthread-posix.c:379
#4  0x00007ffff7b4731d in gst_pad_stop_task (pad=0x78e490) at gstpad.c:5487
#5  0x00007ffff7b42bb4 in gst_pad_activate_mode (pad=0x78e490,
mode=GST_PAD_MODE_PUSH, active=0) at gstpad.c:1084
#6  0x00007ffff7b435a0 in gst_pad_set_active (pad=0x78e490, active=0)
at gstpad.c:970
---Type <return> to continue, or q <return> to quit---
#7  0x00007ffff7b25c04 in activate_pads (vpad=<optimized out>,
ret=0x7fffffffd990, active=0x7fffffffd9ec) at gstelement.c:2687
#8  0x00007ffff7b359ec in gst_iterator_fold (it=0x796040,
func=0x7ffff7b25be0 <activate_pads>, ret=0x7fffffffd990,
user_data=0x7fffffffd9ec) at gstiterator.c:614
#9  0x00007ffff7b25e05 in iterator_activate_fold_with_resync
(iter=0x796040, user_data=0x7fffffffd9ec, func=0x7ffff7b25be0
<activate_pads>) at gstelement.c:2707
#10 0x00007ffff7b27c16 in gst_element_pads_activate (element=0x790060,
active=0) at gstelement.c:2743
#11 0x00007ffff7b27fa5 in gst_element_change_state_func
(element=0x790060, transition=<optimized out>) at gstelement.c:2815
#12 0x00007ffff7b29d2c in gst_element_change_state (element=<optimized
out>, transition=<optimized out>) at gstelement.c:2602
#13 0x00007ffff7b2a6af in gst_element_set_state_func
(element=0x790060, state=GST_STATE_NULL) at gstelement.c:2558
#14 0x0000000000400b08 in main (argc=2, argv=0x7fffffffdc78) at main.c:38
(gdb)


Source:

#include <unistd.h>
#include <assert.h>
#include <stdio.h>

#include <gst/gst.h>

int main(int argc, char *argv[]) {

  /* Initialisation */
  gst_init (&argc, &argv);

  /* Check input arguments */
  if (argc != 2) {
    g_printerr ("Usage: %s <pipeline spec>\n", argv[0]);
    return -1;
  }

  /* Create gstreamer elements */
  GError *error = NULL;
  GstElement *pipeline = gst_parse_launch (argv[1], &error);
  if (!pipeline) {
    g_printerr ("Fail. Exiting.\n");
    return -1;
  }

  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  sleep(2);

  g_print ("Going PAUSED\n");
  gst_element_set_state (pipeline, GST_STATE_PAUSED);

  GstElement *to_delete = gst_bin_get_by_name_recurse_up (GST_BIN
(pipeline), "to_delete");
  assert (to_delete);

  gst_element_set_state (to_delete, GST_STATE_NULL);  // Deadlocks here

  assert(0);  // Isn't reached

  return 0;
}


-- 
Andrey Utkin


More information about the gstreamer-devel mailing list