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 768482 - shmsrc: stopping shmsrc after socket failure hangs on READY
shmsrc: stopping shmsrc after socket failure hangs on READY
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.8.1
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-07-06 12:26 UTC by Marcin Lewandowski
Modified: 2016-07-10 22:02 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Marcin Lewandowski 2016-07-06 12:26:15 UTC
I have a bin that contains shmsrc and capsfilter.

I intercept messages in the bin by overriding handle_message.

If socket from which shmsrc reads is unexpectedly closed I receive an error message in handle_message sent from streaming thread.

I initiate procedure to remove such bin from the pipeline. I set state to NULL, and it never reaches NULL.

This is the log with loglevel *:4

0:00:05.322485951 11568      0x20118f0 INFO              GST_STATES gstbin.c:2316:gst_bin_element_set_state:<capsfilter> current PLAYING pending VOID_PENDING, desired next PAUSED
0:00:05.322575249 11568      0x20118f0 INFO              GST_STATES gstelement.c:2372:gst_element_continue_state:<capsfilter> completed state change to PAUSED
0:00:05.322586658 11568      0x20118f0 INFO              GST_STATES gstelement.c:2277:_priv_gst_element_state_changed:<capsfilter> notifying about state-changed PLAYING to PAUSED (VOID_PENDING pending)
0:00:05.322602931 11568      0x20118f0 INFO              GST_STATES gstbin.c:2764:gst_bin_change_state_func:<Media.Input.Stream.Test-123> child 'capsfilter' changed state to 3(PAUSED) successfully
0:00:05.322677682 11568      0x20118f0 INFO              GST_STATES gstbin.c:2316:gst_bin_element_set_state:<source> current PLAYING pending VOID_PENDING, desired next PAUSED
0:00:05.322724705 11568      0x20118f0 INFO              GST_STATES gstelement.c:2372:gst_element_continue_state:<source> completed state change to PAUSED
0:00:05.322734623 11568      0x20118f0 INFO              GST_STATES gstelement.c:2277:_priv_gst_element_state_changed:<source> notifying about state-changed PLAYING to PAUSED (VOID_PENDING pending)
0:00:05.322755322 11568      0x20118f0 INFO              GST_STATES gstbin.c:2764:gst_bin_change_state_func:<Media.Input.Stream.Test-123> child 'source' changed state to 3(PAUSED) successfully
0:00:05.322774913 11568      0x20118f0 INFO              GST_STATES gstelement.c:2347:gst_element_continue_state:<Media.Input.Stream.Test-123> committing state from PLAYING to PAUSED, pending NULL, next READY
0:00:05.322791096 11568      0x20118f0 INFO              GST_STATES gstelement.c:2277:_priv_gst_element_state_changed:<Media.Input.Stream.Test-123> notifying about state-changed PLAYING to PAUSED (NULL pending)
0:00:05.322851563 11568      0x20118f0 INFO              GST_STATES gstelement.c:2354:gst_element_continue_state:<Media.Input.Stream.Test-123> continue state change PAUSED to READY, final NULL
0:00:05.323275010 11568      0x20118f0 INFO              GST_STATES gstbin.c:2316:gst_bin_element_set_state:<capsfilter> current PAUSED pending VOID_PENDING, desired next READY
0:00:05.323350698 11568      0x20118f0 INFO              GST_STATES gstelement.c:2372:gst_element_continue_state:<capsfilter> completed state change to READY
0:00:05.323394320 11568      0x20118f0 INFO              GST_STATES gstelement.c:2277:_priv_gst_element_state_changed:<capsfilter> notifying about state-changed PAUSED to READY (VOID_PENDING pending)
0:00:05.323412442 11568      0x20118f0 INFO              GST_STATES gstbin.c:2764:gst_bin_change_state_func:<Media.Input.Stream.Test-123> child 'capsfilter' changed state to 2(READY) successfully
0:00:05.323424213 11568      0x20118f0 INFO              GST_STATES gstbin.c:2316:gst_bin_element_set_state:<source> current PAUSED pending VOID_PENDING, desired next READY
Comment 1 Marcin Lewandowski 2016-07-06 12:37:24 UTC
It appears to block the thread.

Stack trace:

(gdb) thr a a bt

Thread 8 (Thread 0x7f9bf37fe700 (LWP 11831))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #2 gst_base_src_set_flushing
    at gstbasesrc.c line 3588
  • #3 gst_base_src_stop
    at gstbasesrc.c line 3535
  • #4 gst_base_src_activate_push
    at gstbasesrc.c line 3709
  • #5 gst_base_src_activate_mode
    at gstbasesrc.c line 3781
  • #6 activate_mode_internal
    at gstpad.c line 1175
  • #7 gst_pad_set_active
    at gstpad.c line 1077
  • #8 activate_pads
    at gstelement.c line 2736
  • #9 gst_iterator_fold
    at gstiterator.c line 614
  • #10 iterator_activate_fold_with_resync
    at gstelement.c line 2760
  • #11 gst_element_pads_activate
    at gstelement.c line 2796
  • #12 gst_element_change_state_func
    at gstelement.c line 2870
  • #13 gst_base_src_change_state
    at gstbasesrc.c line 3818
  • #14 gst_shm_src_change_state
    at gstshmsrc.c line 395
  • #15 gst_element_change_state
    at gstelement.c line 2648
  • #16 gst_element_set_state_func
    at gstelement.c line 2602
  • #17 gst_bin_element_set_state
    at gstbin.c line 2414
  • #18 gst_bin_change_state_func
    at gstbin.c line 2756
  • #19 gst_element_change_state
    at gstelement.c line 2648
  • #20 gst_element_continue_state
    at gstelement.c line 2356
  • #21 gst_element_change_state
    at gstelement.c line 2687
  • #22 gst_element_set_state_func
    at gstelement.c line 2602
  • #23 myapp_common_input_bin_remove_input
    at input_bin.c line 1102
  • #24 ??
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #25 g_signal_emit_valist
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #26 g_signal_emit_by_name
    from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
  • #27 myapp_common_input_bin_input_branch_bin_real_handle_message
    at input_bin.c line 1697
  • #28 bin_bus_handler
    at gstbin.c line 3090
  • #29 gst_bus_post
    at gstbus.c line 327
  • #30 gst_element_post_message_default
    at gstelement.c line 1726
  • #31 gst_element_post_message
    at gstelement.c line 1769
  • #32 gst_element_message_full
    at gstelement.c line 1899
  • #33 gst_shm_src_create
    at gstshmsrc.c line 360
  • #34 gst_base_src_get_range
    at gstbasesrc.c line 2460
  • #35 gst_base_src_loop
    at gstbasesrc.c line 2736
  • #36 gst_task_func
    at gsttask.c line 332
  • #37 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #38 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #39 start_thread
    at pthread_create.c line 333
  • #40 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Comment 2 Marcin Lewandowski 2016-07-06 12:40:56 UTC
Improved stack trace containing glib symbols

(gdb) thr a a bt

Thread 8 (Thread 0x7f9bf37fe700 (LWP 11831))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 g_mutex_lock_slowpath
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthread-posix.c line 1312
  • #2 g_mutex_lock
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthread-posix.c line 1336
  • #3 gst_base_src_set_flushing
    at gstbasesrc.c line 3588
  • #4 gst_base_src_stop
    at gstbasesrc.c line 3535
  • #5 gst_base_src_activate_mode
    at gstbasesrc.c line 3709
  • #6 gst_base_src_activate_mode
    at gstbasesrc.c line 3781
  • #7 activate_mode_internal
    at gstpad.c line 1175
  • #8 gst_pad_set_active
    at gstpad.c line 1077
  • #9 activate_pads
    at gstelement.c line 2736
  • #10 gst_iterator_fold
    at gstiterator.c line 614
  • #11 iterator_activate_fold_with_resync
    at gstelement.c line 2760
  • #12 gst_element_pads_activate
    at gstelement.c line 2796
  • #13 gst_element_change_state_func
    at gstelement.c line 2870
  • #14 gst_base_src_change_state
    at gstbasesrc.c line 3818
  • #15 gst_shm_src_change_state
    at gstshmsrc.c line 395
  • #16 gst_element_change_state
    at gstelement.c line 2648
  • #17 gst_element_set_state_func
    at gstelement.c line 2602
  • #18 gst_bin_change_state_func
    at gstbin.c line 2414
  • #19 gst_bin_change_state_func
    at gstbin.c line 2756
  • #20 gst_element_change_state
    at gstelement.c line 2648
  • #21 gst_element_continue_state
    at gstelement.c line 2356
  • #22 gst_element_change_state
    at gstelement.c line 2687
  • #23 gst_element_set_state_func
    at gstelement.c line 2602
  • #24 radio_kit_plumber_common_input_bin_remove_input
    at input_bin.c line 1102
  • #25 _g_closure_invoke_va
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./gobject/gclosure.c line 867
  • #26 g_signal_emit_valist
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./gobject/gsignal.c line 3294
  • #27 g_signal_emit_by_name
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./gobject/gsignal.c line 3481
  • #28 radio_kit_plumber_common_input_bin_input_branch_bin_real_handle_message
    at input_bin.c line 1697
  • #29 bin_bus_handler
    at gstbin.c line 3090
  • #30 gst_bus_post
    at gstbus.c line 327
  • #31 gst_element_post_message_default
    at gstelement.c line 1726
  • #32 gst_element_post_message
    at gstelement.c line 1769
  • #33 gst_element_message_full
    at gstelement.c line 1899
  • #34 gst_shm_src_create
    at gstshmsrc.c line 360
  • #35 gst_base_src_get_range
    at gstbasesrc.c line 2460
  • #36 gst_base_src_loop
    at gstbasesrc.c line 2736
  • #37 gst_task_func
    at gsttask.c line 332
  • #38 g_thread_pool_thread_proxy
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthreadpool.c line 307
  • #39 g_thread_proxy
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthread.c line 780
  • #40 start_thread
    at pthread_create.c line 333
  • #41 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Comment 3 Marcin Lewandowski 2016-07-06 13:38:10 UTC
It seems that with is-live = true it works fine.
Comment 4 Marcin Lewandowski 2016-07-06 13:44:53 UTC
I am sorry, it does not work fine with is-live = true. It just hangs at the different stage

0:01:17.668145650 29905 0x7f46c8004320 INFO              GST_STATES gstbin.c:2316:gst_bin_element_set_state:<capsfilter> current PLAYING pending VOID_PENDING, desired next PAUSED
0:01:17.668155775 29905 0x7f46c8004320 INFO              GST_STATES gstelement.c:2372:gst_element_continue_state:<capsfilter> completed state change to PAUSED
0:01:17.668160619 29905 0x7f46c8004320 INFO              GST_STATES gstelement.c:2277:_priv_gst_element_state_changed:<capsfilter> notifying about state-changed PLAYING to PAUSED (VOID_PENDING pending)
0:01:17.668170381 29905 0x7f46c8004320 INFO              GST_STATES gstbin.c:2764:gst_bin_change_state_func:<Media.Input.Stream.Test-123> child 'capsfilter' changed state to 3(PAUSED) successfully
0:01:17.668177389 29905 0x7f46c8004320 INFO              GST_STATES gstbin.c:2316:gst_bin_element_set_state:<source> current PLAYING pending VOID_PENDING, desired next PAUSED

It seems that in both cases it hangs on gst_shm_src_stop_reading

(gdb) thr a a bt

Thread 8 (Thread 0x7f1cca7fc700 (LWP 30048))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 g_mutex_lock_slowpath
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthread-posix.c line 1312
  • #2 g_mutex_lock
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthread-posix.c line 1336
  • #3 gst_base_src_set_playing
    at gstbasesrc.c line 3653
  • #4 gst_base_src_change_state
    at gstbasesrc.c line 3828
  • #5 gst_shm_src_change_state
    at gstshmsrc.c line 395
  • #6 gst_element_change_state
    at gstelement.c line 2648
  • #7 gst_element_set_state_func
    at gstelement.c line 2602
  • #8 gst_bin_change_state_func
    at gstbin.c line 2414
  • #9 gst_bin_change_state_func
    at gstbin.c line 2756
  • #10 gst_element_change_state
    at gstelement.c line 2648
  • #11 gst_element_set_state_func
    at gstelement.c line 2602
  • #12 radio_kit_plumber_common_input_bin_remove_input_unlocked
    at input_bin.c line 1230
  • #13 radio_kit_plumber_common_input_bin_remove_input
    at input_bin.c line 884
  • #14 _g_closure_invoke_va
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./gobject/gclosure.c line 867
  • #15 g_signal_emit_valist
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./gobject/gsignal.c line 3294
  • #16 g_signal_emit_by_name
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./gobject/gsignal.c line 3481
  • #17 radio_kit_plumber_common_input_bin_input_branch_bin_real_handle_message
    at input_bin.c line 1815
  • #18 bin_bus_handler
    at gstbin.c line 3090
  • #19 gst_bus_post
    at gstbus.c line 327
  • #20 gst_element_post_message_default
    at gstelement.c line 1726
  • #21 gst_element_post_message
    at gstelement.c line 1769
  • #22 gst_element_message_full
    at gstelement.c line 1899
  • #23 gst_shm_src_create
    at gstshmsrc.c line 360
  • #24 gst_base_src_get_range
    at gstbasesrc.c line 2460
  • #25 gst_base_src_loop
    at gstbasesrc.c line 2736
  • #26 gst_task_func
    at gsttask.c line 332
  • #27 g_thread_pool_thread_proxy
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthreadpool.c line 307
  • #28 g_thread_proxy
    at /build/glib2.0-7IO_Yw/glib2.0-2.48.1/./glib/gthread.c line 780
  • #29 start_thread
    at pthread_create.c line 333
  • #30 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Comment 5 Vincent Penquerc'h 2016-07-07 08:41:30 UTC
The error is triggered from within the _create function, with the stream lock taken. You seem to be removing that element from the pipeline directly, which will need the stream lock.
The triggering of errors from within the _create function seems OK as other sources (eg, v4l2src) also do this. Maybe the best is to do the pipeline change on a g_idle_add function, which will execute without the lock taken (ie, after the streaming thread has exited from the _create function).
Comment 6 Tim-Philipp Müller 2016-07-07 08:55:39 UTC
Indeed, you're not allowed to change state on an element from its streaming thread.
Comment 7 Marcin Lewandowski 2016-07-10 22:02:59 UTC
Vincent, this is exactly what I ended doing. But then I receive an error multiple times until idle callback is called. It's not something horrible, I just set a flag that ensures that I trigger g_idle_add once per error, it works, just looks more like a workaround than something proper.