Skip to content

pad: clear probes holding mutex

Protect clearing probes against concurrent modification which might happen due to dispose does NOT guarantee that the object is not used anymore, as it could be referenced again and so being continued used. So, as in the rest of places where probes hook list is used, on dispose it should be accessed holding the mutex "GST_OBJECT_LOCK (pad);" as GHookList is not thread-safe.

This patch fixes the next issues we come across in our system:

  • g-warnings:
g_hook_ref: assertion 'hook->ref_count > 0' failed
g_hook_unref: assertion 'hook->ref_count > 0' failed
  • SIGSEGs like:
Thread 59 (Thread 0x7f45ff7fe700 (LWP 22655)):
#0  g_hook_ref (hook_list=0x7f4530033008, hook=0xc17f3e9b) at ghook.c:422
#1  0x00007f4683dfaac3 in g_hook_list_clear (hook_list=hook_list@entry=0x7f4530033008) at ghook.c:245
#2  0x00007f46843cd009 in gst_pad_dispose (object=0x7f4530032f70) at gstpad.c:721
#3  0x00007f46841187b5 in g_object_unref (_object=0x7f4530032f70) at gobject.c:3309

We evaluated the count-ref is proper balanced so the unique way we see this can happen is because the list of pad's probes is modified concurrently while it is being cleared. We can see how it is cleared on dispose, which does NOT guarantee that the object is not used anymore, as it could be referenced again and so being continued used.

With this patch we are not able to reproduce the issue anymore.

Edited by Miguel París Díaz

Merge request reports