[Bug 787915] New: watchdog: race between trigger and stop causes deadlock

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Tue Sep 19 18:37:06 UTC 2017


https://bugzilla.gnome.org/show_bug.cgi?id=787915

            Bug ID: 787915
           Summary: watchdog: race between trigger and stop causes
                    deadlock
    Classification: Platform
           Product: GStreamer
           Version: 1.12.2
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gst-plugins-bad
          Assignee: gstreamer-bugs at lists.freedesktop.org
          Reporter: simon.descarries at vantrix.com
        QA Contact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---

There's a potential deadlock when a state change occurs while a timeout is
triggered, the main thread holds the element lock and waits for the worker
thread to finish, but the worker is stuck waiting on the element lock to be
able to issue its error message on the bus.

Backtraces:

Thread 4 (Thread 0x7fa4c37fd700 (LWP 54848)):
#0  0x00007fa506d97ef7 in pthread_join () from /lib64/libpthread.so.0
#1  0x00007fa5078afc97 in g_system_thread_wait () from
/usr/lib/libglib-2.0.so.0
#2  0x00007fa50787b2db in g_thread_join () from /usr/lib/libglib-2.0.so.0
#3  0x00007fa4f58c05f0 in gst_watchdog_stop (trans=0x7fa4e8010200) at
gstwatchdog.c:301
#4  0x00007fa50753c937 in gst_base_transform_activate (trans=0x7fa4e8010200,
active=0) at gstbasetransform.c:2427
#5  0x00007fa50753c9b9 in gst_base_transform_sink_activate_mode
(pad=0x7fa50002cff0, parent=0x7fa4e8010200, mode=GST_PAD_MODE_PUSH, active=0)
at gstbasetransform.c:2447
#6  0x00007fa508592549 in activate_mode_internal (pad=0x7fa50002cff0,
parent=0x7fa4e8010200, mode=GST_PAD_MODE_PUSH, active=0) at gstpad.c:1179
#7  0x00007fa508591f47 in gst_pad_set_active (pad=0x7fa50002cff0, active=0) at
gstpad.c:1080
#8  0x00007fa50856c2ee in activate_pads (vpad=0x7fa4c37fcb50,
ret=0x7fa4c37fcba0, active=0x7fa4c37fcbd4) at gstelement.c:2831
#9  0x00007fa508582e6a in gst_iterator_fold (it=0x7fa4a4002de0,
func=0x7fa50856c29d <activate_pads>, ret=0x7fa4c37fcba0,
user_data=0x7fa4c37fcbd4) at gstiterator.c:617
#10 0x00007fa50856c3c1 in iterator_activate_fold_with_resync
(iter=0x7fa4a4002de0, func=0x7fa50856c29d <activate_pads>,
user_data=0x7fa4c37fcbd4) at gstelement.c:2855
#11 0x00007fa50856c57b in gst_element_pads_activate (element=0x7fa4e8010200,
active=0) at gstelement.c:2899
#12 0x00007fa50856c97e in gst_element_change_state_func
(element=0x7fa4e8010200, transition=GST_STATE_CHANGE_PAUSED_TO_READY) at
gstelement.c:2965
#13 0x00007fa4f58c0b56 in gst_watchdog_change_state (element=0x7fa4e8010200,
transition=GST_STATE_CHANGE_PAUSED_TO_READY) at gstwatchdog.c:394
#14 0x00007fa50856bc87 in gst_element_change_state (element=0x7fa4e8010200,
transition=GST_STATE_CHANGE_PAUSED_TO_READY) at gstelement.c:2743
#15 0x00007fa50856ae1e in gst_element_continue_state (element=0x7fa4e8010200,
ret=GST_STATE_CHANGE_SUCCESS) at gstelement.c:2451
#16 0x00007fa50856c117 in gst_element_change_state (element=0x7fa4e8010200,
transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at gstelement.c:2782
#17 0x00007fa50856b967 in gst_element_set_state_func (element=0x7fa4e8010200,
state=GST_STATE_NULL) at gstelement.c:2697
#18 0x00007fa50856b3fa in gst_element_set_state (element=0x7fa4e8010200,
state=GST_STATE_NULL) at gstelement.c:2598

#0  0x00007fa506d9d1bd in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007fa506d98d38 in _L_lock_975 () from /lib64/libpthread.so.0
#2  0x00007fa506d98ce1 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00007fa5078ae9c9 in g_mutex_lock () from /usr/lib/libglib-2.0.so.0
#4  0x00007fa508568aa9 in gst_element_post_message_default
(element=0x7fa4e8010200, message=0x7fa47c002c10) at gstelement.c:1772
#5  0x00007fa508568e9d in gst_element_post_message (element=0x7fa4e8010200,
message=0x7fa47c002c10) at gstelement.c:1826
#6  0x00007fa5085695d3 in gst_element_message_full_with_details
(element=0x7fa4e8010200, type=GST_MESSAGE_ERROR, domain=2211, code=1,
text=0x7fa4e40011d0 "Watchdog triggered", debug=0x7fa4e4001600 "G",
file=0x7fa4f58c5496 "gstwatchdog.c", function=0x7fa4f58c56f0 <__func__.19336>
"gst_watchdog_trigger", line=193, structure=0x0) at gstelement.c:1962
#7  0x00007fa5085696f3 in gst_element_message_full (element=0x7fa4e8010200,
type=GST_MESSAGE_ERROR, domain=2211, code=1, text=0x7fa4e40011d0 "Watchdog
triggered", debug=0x7fa4e4001600 "G", file=0x7fa4f58c5496 "gstwatchdog.c",
function=0x7fa4f58c56f0 <__func__.19336> "gst_watchdog_trigger", line=193) at
gstelement.c:2001
#8  0x00007fa4f58bfd5f in gst_watchdog_trigger (ptr=0x7fa4e8010200) at
gstwatchdog.c:192
#9  0x00007fa50783c00e in g_timeout_dispatch () from /usr/lib/libglib-2.0.so.0
#10 0x00007fa507839337 in g_main_dispatch () from /usr/lib/libglib-2.0.so.0
#11 0x00007fa50783a8c9 in g_main_context_dispatch () from
/usr/lib/libglib-2.0.so.0
#12 0x00007fa50783aba4 in g_main_context_iterate () from
/usr/lib/libglib-2.0.so.0
#13 0x00007fa50783b1f9 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#14 0x00007fa4f58bfaf7 in gst_watchdog_thread (user_data=0x7fa4e8010200) at
gstwatchdog.c:178



Proposed Fix:

Simply unlock the object before joining the worker thread



--- gst-plugins-bad/gst/debugutils/gstwatchdog.c
+++ gst-plugins-bad/gst/debugutils/gstwatchdog.c
@@ -297,6 +297,7 @@
       NULL);
   g_source_attach (quit_source, watchdog->main_context);
   g_source_unref (quit_source);
+  GST_OBJECT_UNLOCK (watchdog);

   g_thread_join (watchdog->thread);
   watchdog->thread = NULL;
@@ -307,7 +308,6 @@
   g_main_context_unref (watchdog->main_context);
   watchdog->main_context = NULL;

-  GST_OBJECT_UNLOCK (watchdog);
   return TRUE;
 }

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list