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 759539 - Stopping a stream with AAC very soon after starting crashes
Stopping a stream with AAC very soon after starting crashes
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.6.2
Other Linux
: Normal normal
: 1.6.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
1.6.4
Depends on:
Blocks:
 
 
Reported: 2015-12-16 11:16 UTC by davecraig
Modified: 2016-04-14 17:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix (913 bytes, patch)
2015-12-16 11:16 UTC, davecraig
committed Details | Review
Patch for plugins-bad gst_pad_has_current_caps abuse (2.14 KB, patch)
2015-12-16 12:44 UTC, davecraig
committed Details | Review
Patch for plugins-good gst_pad_has_current_caps abuse (6.10 KB, patch)
2015-12-16 12:44 UTC, davecraig
committed Details | Review

Description davecraig 2015-12-16 11:16:12 UTC
Created attachment 317492 [details] [review]
Patch to fix

Using the same test case as bug 759503 the code gets further but now hits different abuse of gst_pad_get_current_caps:

  • #0 raise
    at ../sysdeps/unix/sysv/linux/pt-raise.c line 36
  • #1 _g_log_abort
    at ../../glib-2.44.1/glib/gmessages.c line 315
  • #2 g_logv
  • #3 g_log
  • #4 g_return_if_fail_warning
  • #5 gst_caps_get_structure
    at ../../clone/gst/gstcaps.c line 818
  • #6 gst_aac_parse_get_audio_profile_object_type
    at ../../../clone/gst/audioparsers/gstaacparse.c line 10
  • #7 gst_aac_parse_prepend_adts_headers
  • #8 gst_aac_parse_handle_frame
  • #9 gst_base_parse_handle_buffer
  • #10 gst_base_parse_chain
  • #11 gst_pad_chain_data_unchecked
    at ../../clone/gst/gstpad.c line 4100
  • #12 gst_pad_push_data
    at ../../clone/gst/gstpad.c line 4337
  • #13 gst_single_queue_push_one
  • #14 gst_multi_queue_loop
    at ../../../clone/plugins/elements/gstmultiqueue.c line 1515
  • #15 gst_task_func
    at ../../clone/gst/gsttask.c line 331
  • #16 g_thread_pool_thread_proxy
    at ../../glib-2.44.1/glib/gthreadpool.c line 307
  • #17 g_thread_proxy
    at ../../glib-2.44.1/glib/gthread.c line 764
  • #18 start_thread
    at pthread_create.c line 339
  • #19 __thread_start
    at ../sysdeps/unix/sysv/linux/mips/clone.S line 144

Comment 1 Sebastian Dröge (slomo) 2015-12-16 11:25:06 UTC
Can you check the other audio/video parsers too for more of the similar problem?
Comment 2 davecraig 2015-12-16 11:57:29 UTC
(In reply to Sebastian Dröge (slomo) from comment #1)
> Can you check the other audio/video parsers too for more of the similar
> problem?
Yes, I did take a look. None of the audio or video parsers looked to have a similar problem.

However, some of the other plugins had things that I thought looked sketchy. Using gst_pad_has_current_caps() to decide whether to call gst_pad_get_current_caps e.g. from gst_flac_enc_sink_query


      if (gst_pad_has_current_caps (pad)) {
        acceptable = gst_pad_get_current_caps (pad);
      } else {
        acceptable = gst_pad_get_pad_template_caps (pad);
      }

This would seem better:

      acceptable = gst_pad_get_current_caps (pad);
      if(acceptable == NULL) {
        acceptable = gst_pad_get_pad_template_caps (pad);
      }

Anywhere that calls gst_pad_get_current_caps based on the result of gst_pad_has_current_caps looks to me to be problematic. These are the ones I found:

gst_flac_enc_getcaps
gst_flac_enc_sink_query
gst_shape_wipe_video_sink_getcaps
gst_shape_wipe_mask_sink_getcaps
gst_shape_wipe_src_getcaps
gst_flv_mux_create_metadata
gst_image_freeze_sink_getcaps
gst_aspect_ratio_crop_set_property
gst_rtp_h264_set_src_caps
gst_disparity_handle_query
gst_rtp_h265_set_src_caps

The other places that looked problematic were in demuxes, though it may be that these are ok e.g. call to gst_pad_get_current_caps in gst_deinterlace_output_frame. I guess all calls to gst_pad_get_current_caps checking for NULL is the only way to be sure.
Comment 3 Sebastian Dröge (slomo) 2015-12-16 12:07:28 UTC
Agreed
Comment 4 davecraig 2015-12-16 12:44:18 UTC
Created attachment 317495 [details] [review]
Patch for plugins-bad gst_pad_has_current_caps abuse
Comment 5 davecraig 2015-12-16 12:44:44 UTC
Created attachment 317496 [details] [review]
Patch for plugins-good gst_pad_has_current_caps abuse
Comment 6 Sebastian Dröge (slomo) 2015-12-16 12:52:34 UTC
Thanks, did you also check gst-plugins-ugly, gst-plugins-base, gst-libav and gstreamer core?
Comment 7 davecraig 2015-12-16 13:07:04 UTC
(In reply to Sebastian Dröge (slomo) from comment #6)
> Thanks, did you also check gst-plugins-ugly, gst-plugins-base, gst-libav and
> gstreamer core?
I checked gstreamer-core and it looked ok, but nothing else. I'll be working through them over the next few days.
Comment 8 Sebastian Dröge (slomo) 2015-12-16 13:21:55 UTC
Thanks, looks all good so far (but please run gst-indent on your future changes, on the source files only, not headers).

I expect some more of these in gst-plugins-base, including some places in e.g. the audio/video codec base classes.
Comment 9 Sebastian Dröge (slomo) 2015-12-16 15:05:27 UTC
Where exactly are the caps removed from the pad btw? I wonder if that shouldn't take the stream lock and as not just drop the caps while data processing happens.
Comment 10 davecraig 2015-12-16 15:27:41 UTC
> Where exactly are the caps removed from the pad btw?
For the assert in comment 1 I think it's happening as I described in bug 759503 comment 1 - pre_activate inside gst_pad_activate_mode. However, that may not be correct. I had originally imagined that a larger lock (stream lock) would be in use but I'm not overly clear on the gstreamer locking strategy.
Comment 11 Sebastian Dröge (slomo) 2015-12-16 16:29:09 UTC
post_activate() will remove all the events, and as such the caps. And that one is taking the stream lock.

Problem here is that this happens on the srcpad... and the srcpad's stream lock is not taken during data processing in all these elements. Only the sinkpad's stream lock. So I guess for all these patches, only the ones related to srcpads are valid.
Comment 12 Sebastian Dröge (slomo) 2015-12-17 09:39:17 UTC
Anyway, I'll merge all this when you or someone else went through the other modules. For the srcpads we should do checks like this, it also seems a bit silly to split the checks up into two parts (if (has) get) instead of just getting and checking for NULL.

We should probably also add a comment to the docs of gst_pad_has_current_caps() regarding that.