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 784012 - decodebin3: Protect dbin->collection with the SELECTION_LOCK
decodebin3: Protect dbin->collection with the SELECTION_LOCK
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other All
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-06-20 19:26 UTC by Thibault Saunier
Modified: 2017-07-18 11:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
decodebin3: Protect dbin->collection with the SELECTION_LOCK (4.25 KB, patch)
2017-06-20 19:26 UTC, Thibault Saunier
none Details | Review
decodebin3: Protect fields related to streams handling with the SELECTION_LOCK (9.68 KB, patch)
2017-07-13 14:24 UTC, Thibault Saunier
committed Details | Review
decodebin3: Protect dbin->collection usage (3.75 KB, patch)
2017-07-13 15:41 UTC, Edward Hervey
committed Details | Review

Description Thibault Saunier 2017-06-20 19:26:25 UTC
The current collection was not protected at all and we were easily using
it after free on rtsp streams.
Comment 1 Thibault Saunier 2017-06-20 19:26:30 UTC
Created attachment 354112 [details] [review]
decodebin3: Protect dbin->collection with the SELECTION_LOCK

It was currently not protected at all which was leading to a race
where we were using dbin->collection after it was freed.
Comment 2 Thibault Saunier 2017-06-20 19:48:45 UTC
A simple way to reproduce the race is by doing:

USE_PLAYBIN3=true gst-validate-launcher -m -t validate.rtsp.playback.change_state_intensive.test5_mkv

Traceback:

Thread 23 "rtpjitterbuffer" received signal SIGSEGV, Segmentation fault.

Thread 140735894492928 (LWP 32571)

  • #0 gst_stream_get_stream_id
    at ../subprojects/gstreamer/gst/gststreams.c line 265
  • #1 update_requested_selection
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c line 1039
  • #2 gst_decodebin3_handle_message
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c line 1318
  • #3 bin_bus_handler
    at ../subprojects/gstreamer/gst/gstbin.c line 3267
  • #4 gst_bus_post
    at ../subprojects/gstreamer/gst/gstbus.c line 336
  • #5 gst_element_post_message_default
    at ../subprojects/gstreamer/gst/gstelement.c line 1789
  • #6 gst_bin_post_message
    at ../subprojects/gstreamer/gst/gstbin.c line 2796
  • #7 gst_element_post_message
    at ../subprojects/gstreamer/gst/gstelement.c line 1832
  • #8 gst_parse_bin_expose
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 3499
  • #9 pad_added_cb
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 2454
  • #10 caps_notify_cb
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 2562
  • #11 g_closure_invoke
  • #12 0x00007ffff72d14ee in
  • #13 g_signal_emit_valist
  • #14 g_signal_emit
  • #15 0x00007ffff72c3134 in
  • #16 gst_object_dispatch_properties_changed
    at ../subprojects/gstreamer/gst/gstobject.c line 427
  • #17 g_object_notify_by_pspec
  • #18 store_sticky_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5105
  • #19 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5383
  • #20 gst_pad_set_caps
    at ../subprojects/gstreamer/gst/gstcompat.h line 59
  • #21 gst_aac_parse_set_src_caps
    at ../subprojects/gst-plugins-good/gst/audioparsers/gstaacparse.c line 271
  • #22 gst_aac_parse_sink_setcaps
    at ../subprojects/gst-plugins-good/gst/audioparsers/gstaacparse.c line 334
  • #23 gst_base_parse_sink_event_default
    at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c line 1152
  • #24 gst_base_parse_sink_event
    at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c line 1117
  • #25 gst_validate_pad_monitor_downstream_event_check
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 1947
  • #26 gst_validate_pad_monitor_sink_event_full_func
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 2298
  • #27 gst_validate_pad_monitor_sink_event_func
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 2311
  • #28 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #29 gst_pad_send_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5778
  • #30 send_sticky_event
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 1637
  • #31 foreach_dispatch_function
    at ../subprojects/gstreamer/gst/gstpad.c line 5877
  • #32 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #33 gst_pad_sticky_events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 5908
  • #34 send_sticky_events
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 1652
  • #35 connect_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 2178
  • #36 analyze_new_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 1483
  • #37 connect_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 2205
  • #38 analyze_new_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 1483
  • #39 type_found
    at ../subprojects/gst-plugins-base/gst/playback/gstparsebin.c line 2392
  • #40 ffi_call_unix64
  • #41 ffi_call
  • #42 g_cclosure_marshal_generic
  • #43 g_closure_invoke
  • #44 0x00007ffff72d14ee in
  • #45 g_signal_emit_valist
  • #46 g_signal_emit
  • #47 gst_type_find_element_emit_have_type
    at ../subprojects/gstreamer/plugins/elements/gsttypefindelement.c line 238
  • #48 gst_type_find_element_setcaps
    at ../subprojects/gstreamer/plugins/elements/gsttypefindelement.c line 790
  • #49 gst_type_find_element_sink_event
    at ../subprojects/gstreamer/plugins/elements/gsttypefindelement.c line 680
  • #50 gst_validate_pad_monitor_downstream_event_check
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 1947
  • #51 gst_validate_pad_monitor_sink_event_full_func
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 2298
  • #52 gst_validate_pad_monitor_sink_event_func
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 2311
  • #53 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #54 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5264
  • #55 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3807
  • #56 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #57 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3864
  • #58 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5395
  • #59 event_forward_func
    at ../subprojects/gstreamer/gst/gstpad.c line 2992
  • #60 gst_pad_forward
    at ../subprojects/gstreamer/gst/gstpad.c line 2946
  • #61 gst_pad_event_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3043
  • #62 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #63 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5264
  • #64 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3807
  • #65 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #66 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3864
  • #67 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5395
  • #68 event_forward_func
    at ../subprojects/gstreamer/gst/gstpad.c line 2992
  • #69 gst_pad_forward
    at ../subprojects/gstreamer/gst/gstpad.c line 2946
  • #70 gst_pad_event_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3043
  • #71 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #72 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5264
  • #73 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3807
  • #74 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #75 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3864
  • #76 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5395
  • #77 event_forward_func
    at ../subprojects/gstreamer/gst/gstpad.c line 2992
  • #78 gst_pad_forward
    at ../subprojects/gstreamer/gst/gstpad.c line 2946
  • #79 gst_pad_event_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3043
  • #80 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #81 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5264
  • #82 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3807
  • #83 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #84 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3864
  • #85 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5395
  • #86 gst_rtspsrc_handle_src_sink_event
    at ../subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c line 2359
  • #87 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #88 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5264
  • #89 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3807
  • #90 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #91 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3864
  • #92 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5395
  • #93 event_forward_func
    at ../subprojects/gstreamer/gst/gstpad.c line 2992
  • #94 gst_pad_forward
    at ../subprojects/gstreamer/gst/gstpad.c line 2946
  • #95 gst_pad_event_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3043
  • #96 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5608
  • #97 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5264
  • #98 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3807
  • #99 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 604
  • #100 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3864
  • #101 gst_pad_push_data
    at ../subprojects/gstreamer/gst/gstpad.c line 4435
  • #102 gst_pad_push
    at ../subprojects/gstreamer/gst/gstpad.c line 4576
  • #103 gst_rtp_pt_demux_chain
    at ../subprojects/gst-plugins-good/gst/rtpmanager/gstrtpptdemux.c line 442
  • #104 gst_validate_pad_monitor_chain_func
    at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c line 2234
  • #105 gst_pad_chain_data_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 4205
  • #106 gst_pad_push_data
    at ../subprojects/gstreamer/gst/gstpad.c line 4457
  • #107 gst_pad_push
    at ../subprojects/gstreamer/gst/gstpad.c line 4576
  • #108 pop_and_push_next
    at ../subprojects/gst-plugins-good/gst/rtpmanager/gstrtpjitterbuffer.c line 3380
  • #109 handle_next_buffer
    at ../subprojects/gst-plugins-good/gst/rtpmanager/gstrtpjitterbuffer.c line 3479
  • #110 gst_rtp_jitter_buffer_loop
    at ../subprojects/gst-plugins-good/gst/rtpmanager/gstrtpjitterbuffer.c line 4025
  • #111 gst_task_func
    at ../subprojects/gstreamer/gst/gsttask.c line 332
  • #112 default_func
    at ../subprojects/gstreamer/gst/gsttaskpool.c line 69
  • #113 0x00007ffff7574490 in
  • #114 0x00007ffff7573ac5 in
  • #115 start_thread
  • #116 clone

Comment 3 Thibault Saunier 2017-07-13 14:24:14 UTC
Created attachment 355518 [details] [review]
decodebin3: Protect fields related to streams handling with the SELECTION_LOCK

Fields related to stream handling (input_streams,
output_streams, slots, guint slot_id) where used totally unprotected
until know.

This lead to several races, especially playing back RTSP streams.

To protect those fields, the OBJECT_LOCK can not be used as we sometimes
need to be able to post message on the bus while holding it.

decodebin3 already has a lock to manage stream selection, and in the end
it makes sense to protect all the stream management fields with the same
lock which is why we reuse the SELECTION_LOCK here.
Comment 4 Edward Hervey 2017-07-13 15:41:17 UTC
Created attachment 355528 [details] [review]
decodebin3: Protect dbin->collection usage

Use the selection lock to protect dbin->collection access
Comment 5 Edward Hervey 2017-07-18 11:07:53 UTC
commit 4b3798fedcd5be1aa76092e91a7d22663100d99f
Author: Thibault Saunier <thibault.saunier@osg.samsung.com>
Date:   Thu Jun 15 12:48:42 2017 -0400

    decodebin3: Protect fields related to streams handling with the SELECTION_LOCK
    
    Fields related to stream handling (input_streams,
    output_streams, slots, guint slot_id) where used totally unprotected
    until know.
    
    This lead to several races, especially playing back RTSP streams.
    
    To protect those fields, the OBJECT_LOCK can not be used as we sometimes
    need to be able to post message on the bus while holding it.
    
    decodebin3 already has a lock to manage stream selection, and in the end
    it makes sense to protect all the stream management fields with the same
    lock which is why we reuse the SELECTION_LOCK here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784012

commit 1188345886af566c306c6a9cfe9e08367860bfb1
Author: Edward Hervey <edward@centricular.com>
Date:   Thu Jul 13 17:39:58 2017 +0200

    decodebin3: Protect dbin->collection usage
    
    Use the selection lock to protect dbin->collection access
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784012
Comment 6 Edward Hervey 2017-07-18 11:09:10 UTC
Comment on attachment 355518 [details] [review]
decodebin3: Protect fields related to streams handling with the SELECTION_LOCK

Commited without changes for collection access (in the other patch)