[Bug 720661] New: [PATCH] fix locking bug accessing ring buffer time in base audiosink

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Wed Dec 18 01:39:50 PST 2013


https://bugzilla.gnome.org/show_bug.cgi?id=720661
  GStreamer | gst-plugins-base | unspecified

           Summary: [PATCH] fix locking bug accessing ring buffer time in
                    base audiosink
    Classification: Platform
           Product: GStreamer
           Version: unspecified
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gst-plugins-base
        AssignedTo: gstreamer-bugs at lists.freedesktop.org
        ReportedBy: vincent.penquerch at collabora.co.uk
         QAContact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---


Created an attachment (id=264467)
 View: https://bugzilla.gnome.org/attachment.cgi?id=264467
 Review: https://bugzilla.gnome.org/review?bug=720661&attachment=264467

Lock ring buffer acess from query function

A position query from downstream could happen while the setcaps
function was being called (this can happen when the query comes
from a glib timeout function). The ring buffer could then be
released between gst_audio_base_sink_get_time checking rate==0
and using it to scale samples to time, ending up dividing by 0.

Note that I am not 100% sure it it always safe to get the stream lock here,
it seems to work though.

Relevant backtrace threads follow:

Thread 6 (Thread 0x7fe9aa6dc700 (LWP 6383)):
#0  __lll_unlock_wake () at
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:368
#1  0x00007fe9bf6ac104 in _L_unlock_644 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007fe9bf6ac063 in __pthread_mutex_unlock_usercnt (mutex=<optimised
out>, decr=<optimised out>)
    at pthread_mutex_unlock.c:52
#3  __pthread_mutex_unlock (mutex=0x7fe9b004d5b0) at pthread_mutex_unlock.c:290
#4  0x00007fe9bf9415e1 in g_mutex_unlock () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007fe9bee6985c in gst_audio_ring_buffer_release (buf=0x7fe9b0052090)
    at gstaudioringbuffer.c:696
#6  0x00007fe9bee827b6 in gst_audio_base_sink_setcaps (bsink=0x7fe9b004e4e0,
caps=0x148aca0)
    at gstaudiobasesink.c:870
#7  0x00007fe9bdecdd23 in gst_base_sink_default_event (basesink=0x7fe9b004e4e0,
event=0x7fe99c003580)
    at gstbasesink.c:3036
#8  0x00007fe9bdec995d in gst_base_sink_event (pad=<optimised out>,
parent=0x7fe9b004e4e0, 
    event=0x7fe99c003580) at gstbasesink.c:3138
#9  0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x15e9830,
event=0x7fe99c003580, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#10 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x15ef6c0,
event=0x7fe99c003580, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
#11 0x00007fe9bfe65c28 in push_sticky (pad=0x15ef6c0, ev=0x7fe9aa6d9e30,
user_data=0x7fe9aa6d9ea0)
    at gstpad.c:3324
#12 0x00007fe9bfe63452 in events_foreach (pad=0x15ef6c0, func=0x7fe9bfe65ad0
<push_sticky>, 
    user_data=0x7fe9aa6d9ea0) at gstpad.c:533
#13 0x00007fe9bfe6d838 in check_sticky (event=0x7fe99c003580, pad=0x15ef6c0) at
gstpad.c:3380
#14 gst_pad_push_event (pad=0x15ef6c0, event=0x7fe99c003580) at gstpad.c:4808
---Type <return> to continue, or q <return> to quit---
#15 0x00007fe9bfe6d9c7 in event_forward_func (pad=0x15ef6c0,
data=0x7fe9aa6d9ff0) at gstpad.c:2741
#16 0x00007fe9bfe6b1da in gst_pad_forward (pad=0x14c9800,
forward=0x7fe9bfe6d8f0 <event_forward_func>, 
    user_data=0x7fe9aa6d9ff0) at gstpad.c:2695
#17 0x00007fe9bfe6b999 in gst_pad_event_default (pad=<optimised out>,
parent=<optimised out>, 
    event=0x7fe99c003580) at gstpad.c:2792
#18 0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x14c9800,
event=0x7fe99c003580, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#19 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x14c9cc0,
event=0x7fe99c003580, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
#20 0x00007fe9bfe65c28 in push_sticky (pad=0x14c9cc0, ev=0x7fe9aa6da310,
user_data=0x7fe9aa6da380)
    at gstpad.c:3324
#21 0x00007fe9bfe63452 in events_foreach (pad=0x14c9cc0, func=0x7fe9bfe65ad0
<push_sticky>, 
    user_data=0x7fe9aa6da380) at gstpad.c:533
#22 0x00007fe9bfe6d838 in check_sticky (event=0x7fe99c003580, pad=0x14c9cc0) at
gstpad.c:3380
#23 gst_pad_push_event (pad=0x14c9cc0, event=0x7fe99c003580) at gstpad.c:4808
#24 0x00007fe9bfe6d9c7 in event_forward_func (pad=0x14c9cc0,
data=0x7fe9aa6da4d0) at gstpad.c:2741
#25 0x00007fe9bfe6b1da in gst_pad_forward (pad=0x15efb40,
forward=0x7fe9bfe6d8f0 <event_forward_func>, 
    user_data=0x7fe9aa6da4d0) at gstpad.c:2695
#26 0x00007fe9bfe6b999 in gst_pad_event_default (pad=<optimised out>,
parent=<optimised out>, 
    event=0x7fe99c003580) at gstpad.c:2792
#27 0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x15efb40,
event=0x7fe99c003580, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#28 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x7fe9b00744a0,
event=0x7fe99c003580, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
#29 0x00007fe9bfe65c28 in push_sticky (pad=0x7fe9b00744a0, ev=0x7fe9aa6da7f0,
user_data=0x7fe9aa6da860)
    at gstpad.c:3324
#30 0x00007fe9bfe63452 in events_foreach (pad=0x7fe9b00744a0,
func=0x7fe9bfe65ad0 <push_sticky>, 
    user_data=0x7fe9aa6da860) at gstpad.c:533
#31 0x00007fe9bfe6d838 in check_sticky (event=0x7fe99c003580,
pad=0x7fe9b00744a0) at gstpad.c:3380
#32 gst_pad_push_event (pad=0x7fe9b00744a0, event=0x7fe99c003580) at
gstpad.c:4808
#33 0x00007fe9bdee2c58 in gst_pad_set_caps (caps=0x148aca0, pad=0x7fe9b00744a0)
    at ../../../gst/gstcompat.h:55
#34 gst_base_transform_setcaps (trans=0x7fe9b0081500, pad=<optimised out>,
incaps=<optimised out>)
    at gstbasetransform.c:1348
#35 0x00007fe9bdee3d8d in gst_base_transform_sink_eventfunc
(trans=0x7fe9b0081500, 
    event=0x7fe99c003520) at gstbasetransform.c:1860
---Type <return> to continue, or q <return> to quit---
#36 0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x7fe9b0074270,
event=0x7fe99c003520, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#37 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x7fe9b0074d60,
event=0x7fe99c003520, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
#38 0x00007fe9bfe65c28 in push_sticky (pad=0x7fe9b0074d60, ev=0x7fe9aa6dad00,
user_data=0x7fe9aa6dad70)
    at gstpad.c:3324
#39 0x00007fe9bfe63452 in events_foreach (pad=0x7fe9b0074d60,
func=0x7fe9bfe65ad0 <push_sticky>, 
    user_data=0x7fe9aa6dad70) at gstpad.c:533
#40 0x00007fe9bfe6d838 in check_sticky (event=0x7fe99c003520,
pad=0x7fe9b0074d60) at gstpad.c:3380
#41 gst_pad_push_event (pad=0x7fe9b0074d60, event=0x7fe99c003520) at
gstpad.c:4808
#42 0x00007fe9bdee2c58 in gst_pad_set_caps (caps=0x148aca0, pad=0x7fe9b0074d60)
    at ../../../gst/gstcompat.h:55
#43 gst_base_transform_setcaps (trans=0x7fe9b0086600, pad=<optimised out>,
incaps=<optimised out>)
    at gstbasetransform.c:1348
#44 0x00007fe9bdee3d8d in gst_base_transform_sink_eventfunc
(trans=0x7fe9b0086600, 
    event=0x7fe99c0034c0) at gstbasetransform.c:1860
#45 0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x7fe9b00753f0,
event=0x7fe99c0034c0, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#46 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x7fe9b00751c0,
event=0x7fe99c0034c0, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
#47 0x00007fe9bfe65c28 in push_sticky (pad=0x7fe9b00751c0, ev=0x7fe9aa6db210,
user_data=0x7fe9aa6db280)
    at gstpad.c:3324
#48 0x00007fe9bfe63452 in events_foreach (pad=0x7fe9b00751c0,
func=0x7fe9bfe65ad0 <push_sticky>, 
    user_data=0x7fe9aa6db280) at gstpad.c:533
#49 0x00007fe9bfe6d838 in check_sticky (event=0x7fe99c0034c0,
pad=0x7fe9b00751c0) at gstpad.c:3380
#50 gst_pad_push_event (pad=0x7fe9b00751c0, event=0x7fe99c0034c0) at
gstpad.c:4808
#51 0x00007fe9bdee2c58 in gst_pad_set_caps (caps=0x148aca0, pad=0x7fe9b00751c0)
    at ../../../gst/gstcompat.h:55
#52 gst_base_transform_setcaps (trans=0x7fe9b0084720, pad=<optimised out>,
incaps=<optimised out>)
    at gstbasetransform.c:1348
#53 0x00007fe9bdee3d8d in gst_base_transform_sink_eventfunc
(trans=0x7fe9b0084720, 
    event=0x7fe994002300) at gstbasetransform.c:1860
#54 0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x7fe9b0074f90,
event=0x7fe994002300, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#55 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x15ef900,
event=0x7fe994002300, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
---Type <return> to continue, or q <return> to quit---
#56 0x00007fe9bfe65c28 in push_sticky (pad=0x15ef900, ev=0x7fe9aa6db720,
user_data=0x7fe9aa6db790)
    at gstpad.c:3324
#57 0x00007fe9bfe63452 in events_foreach (pad=0x15ef900, func=0x7fe9bfe65ad0
<push_sticky>, 
    user_data=0x7fe9aa6db790) at gstpad.c:533
#58 0x00007fe9bfe6d838 in check_sticky (event=0x7fe994002300, pad=0x15ef900) at
gstpad.c:3380
#59 gst_pad_push_event (pad=0x15ef900, event=0x7fe994002300) at gstpad.c:4808
#60 0x00007fe9bfe6d9c7 in event_forward_func (pad=0x15ef900,
data=0x7fe9aa6db8e0) at gstpad.c:2741
#61 0x00007fe9bfe6b1da in gst_pad_forward (pad=0x14c9a60,
forward=0x7fe9bfe6d8f0 <event_forward_func>, 
    user_data=0x7fe9aa6db8e0) at gstpad.c:2695
#62 0x00007fe9bfe6b999 in gst_pad_event_default (pad=<optimised out>,
parent=<optimised out>, 
    event=0x7fe994002300) at gstpad.c:2792
#63 0x00007fe9bd84913d in gst_play_sink_convert_bin_sink_event (pad=0x14c9a60,
parent=0x7fe9b0076000, 
    event=0x7fe994002300) at gstplaysinkconvertbin.c:254
#64 0x00007fe9bfe64e8d in gst_pad_send_event_unchecked (pad=0x14c9a60,
event=0x7fe994002300, 
    type=GST_PAD_PROBE_TYPE_IDLE) at gstpad.c:4995
#65 0x00007fe9bfe65622 in gst_pad_push_event_unchecked (pad=0x15e9a60,
event=0x7fe994002300, 
    type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at gstpad.c:4691
#66 0x00007fe9bfe65c28 in push_sticky (pad=0x15e9a60, ev=0x7fe9aa6dbc80,
user_data=0x7fe9aa6dbcf0)
    at gstpad.c:3324
#67 0x00007fe9bfe63452 in events_foreach (pad=0x15e9a60, func=0x7fe9bfe65ad0
<push_sticky>, 
    user_data=0x7fe9aa6dbcf0) at gstpad.c:533
#68 0x00007fe9bfe6d838 in check_sticky (event=0x7fe994002300, pad=0x15e9a60) at
gstpad.c:3380
#69 gst_pad_push_event (pad=0x15e9a60, event=0x7fe994002300) at gstpad.c:4808
#70 0x00007fe9bd5ecfff in gst_queue_push_one (queue=0x7fe9b0042410) at
gstqueue.c:1176
#71 gst_queue_loop (pad=<optimised out>) at gstqueue.c:1253
#72 0x00007fe9bfe94f1f in gst_task_func (task=0x15f2b40) at gsttask.c:316
#73 0x00007fe9bf928218 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#74 0x00007fe9bf9279b5 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#75 0x00007fe9bf6a8e9a in start_thread (arg=0x7fe9aa6dc700) at
pthread_create.c:308
#76 0x00007fe9bf3d53fd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#77 0x0000000000000000 in ?? ()


Thread 1 (Thread 0x7fe9c051b700 (LWP 6379)):
#0  0x00007fe9bf90cf9b in g_logv () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007fe9bf90d172 in g_log () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fe9bfe9a87a in _gst_util_uint64_scale_int (val=<optimised out>,
num=<optimised out>, 
    denom=<optimised out>, correct=<optimised out>) at gstutils.c:586
#3  0x00007fe9bee7e073 in gst_audio_base_sink_get_time (sink=0x7fe9b004e4e0,
clock=<optimised out>)
    at gstaudiobasesink.c:540
#4  gst_audio_base_sink_get_time (clock=<optimised out>, sink=0x7fe9b004e4e0)
at gstaudiobasesink.c:519
#5  0x00007fe9bee6ad33 in gst_audio_clock_get_internal_time (clock=<optimised
out>)
    at gstaudioclock.c:192
#6  0x00007fe9bfe462f5 in gst_clock_get_internal_time (clock=0x7fe9b004f120) at
gstclock.c:949
#7  0x00007fe9bfe46484 in gst_clock_get_time (clock=0x7fe9b004f120) at
gstclock.c:989
#8  0x00007fe9bdecd6d7 in gst_base_sink_get_position (basesink=0x7fe9b004e4e0,
format=GST_FORMAT_TIME, 
    cur=0x7fffc8bef080, upstream=0x7fffc8bef098) at gstbasesink.c:4500
#9  0x00007fe9bded1a57 in default_element_query (element=<optimised out>,
query=0x14cf400)
    at gstbasesink.c:4630
#10 0x00007fe9bee82be3 in gst_audio_base_sink_query (element=0x7fe9b004e4e0,
query=0x14cf400)
    at gstaudiobasesink.c:509
#11 0x00007fe9bfe3034b in bin_query_position_fold (vitem=<optimised out>,
ret=0x7fffc8bef260, 
---Type <return> to continue, or q <return> to quit---
    fold=0x7fffc8bef2c0) at gstbin.c:3818
#12 0x00007fe9bfe5cf7c in gst_iterator_fold (it=0x1456590, 
    func=0x7fe9bfe302e0 <bin_query_position_fold>, ret=0x7fffc8bef260,
user_data=0x7fffc8bef2c0)
    at gstiterator.c:614
#13 0x00007fe9bfe2fb80 in bin_iterate_fold (bin=0x7fe9b0047000, iter=0x1456590, 
    fold_init=0x7fe9bfe2ea20 <bin_query_min_max_init>, 
    fold_done=0x7fe9bfe33b80 <bin_query_position_done>, 
    fold_func=0x7fe9bfe302e0 <bin_query_position_fold>, fold_data=...,
default_return=0)
    at gstbin.c:3935
#14 0x00007fe9bfe351a7 in gst_bin_query (element=0x7fe9b0047000,
query=0x14cf400) at gstbin.c:4045
#15 0x00007fe9bfe3034b in bin_query_position_fold (vitem=<optimised out>,
ret=0x7fffc8bef410, 
    fold=0x7fffc8bef470) at gstbin.c:3818
#16 0x00007fe9bfe5cf7c in gst_iterator_fold (it=0x14564e0, 
    func=0x7fe9bfe302e0 <bin_query_position_fold>, ret=0x7fffc8bef410,
user_data=0x7fffc8bef470)
    at gstiterator.c:614
#17 0x00007fe9bfe2fb80 in bin_iterate_fold (bin=0x7fe9b004f2c0, iter=0x14564e0, 
    fold_init=0x7fe9bfe2ea20 <bin_query_min_max_init>, 
    fold_done=0x7fe9bfe33b80 <bin_query_position_done>, 
    fold_func=0x7fe9bfe302e0 <bin_query_position_fold>, fold_data=...,
default_return=0)
    at gstbin.c:3935
#18 0x00007fe9bfe351a7 in gst_bin_query (element=0x7fe9b004f2c0,
query=0x14cf400) at gstbin.c:4045
#19 0x00007fe9bfe3034b in bin_query_position_fold (vitem=<optimised out>,
ret=0x7fffc8bef5c0, 
    fold=0x7fffc8bef620) at gstbin.c:3818
#20 0x00007fe9bfe5cf7c in gst_iterator_fold (it=0x1456430, 
    func=0x7fe9bfe302e0 <bin_query_position_fold>, ret=0x7fffc8bef5c0,
user_data=0x7fffc8bef620)
    at gstiterator.c:614
#21 0x00007fe9bfe2fb80 in bin_iterate_fold (bin=0x15d00a0, iter=0x1456430, 
    fold_init=0x7fe9bfe2ea20 <bin_query_min_max_init>, 
    fold_done=0x7fe9bfe33b80 <bin_query_position_done>, 
    fold_func=0x7fe9bfe302e0 <bin_query_position_fold>, fold_data=...,
default_return=0)
    at gstbin.c:3935
#22 0x00007fe9bfe351a7 in gst_bin_query (element=0x15d00a0, query=0x14cf400) at
gstbin.c:4045
#23 0x00007fe9bfe3034b in bin_query_position_fold (vitem=<optimised out>,
ret=0x7fffc8bef770, 
    fold=0x7fffc8bef7d0) at gstbin.c:3818
#24 0x00007fe9bfe5cf7c in gst_iterator_fold (it=0x1456380, 
    func=0x7fe9bfe302e0 <bin_query_position_fold>, ret=0x7fffc8bef770,
user_data=0x7fffc8bef7d0)
---Type <return> to continue, or q <return> to quit---
    at gstiterator.c:614
#25 0x00007fe9bfe2fb80 in bin_iterate_fold (bin=0x15cb690, iter=0x1456380, 
    fold_init=0x7fe9bfe2ea20 <bin_query_min_max_init>, 
    fold_done=0x7fe9bfe33b80 <bin_query_position_done>, 
    fold_func=0x7fe9bfe302e0 <bin_query_position_fold>, fold_data=...,
default_return=0)
    at gstbin.c:3935
#26 0x00007fe9bfe351a7 in gst_bin_query (element=0x15cb690, query=0x14cf400) at
gstbin.c:4045
#27 0x00007fe9bd82b6c4 in gst_play_bin_query (element=0x15cb690,
query=0x14cf400) at gstplaybin2.c:2663
#28 0x00007fe9bfe9b951 in gst_element_query_position (element=0x15cb690,
format=<optimised out>, 
    cur=0x7fffc8bef900) at gstutils.c:2162
#29 0x000000000040239b in play_timeout (user_data=0x15c5c90) at gst-play.c:283
#30 0x00007fe9bf9068db in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#31 0x00007fe9bf905d13 in g_main_context_dispatch () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x00007fe9bf906060 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#33 0x00007fe9bf90645a in g_main_loop_run () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#34 0x00000000004020df in do_play (play=<optimised out>) at gst-play.c:393
#35 main (argc=1, argv=0x7fffc8befd28) at gst-play.c:512

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- 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