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 652642 - typefind: NULL check in degas_type_find
typefind: NULL check in degas_type_find
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 0.10.36
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-06-15 12:16 UTC by Philip Jägenstedt
Modified: 2011-06-28 09:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
NULL check result of gst_type_find_peek (1.60 KB, patch)
2011-06-15 12:17 UTC, Philip Jägenstedt
committed Details | Review

Description Philip Jägenstedt 2011-06-15 12:16:58 UTC
I got a segfault in degas_type_find, with this backtrace:

  • #0 degas_type_find
    at gsttypefindfunctions.c line 4081
  • #1 gst_type_find_factory_call_function
    at gsttypefindfactory.c line 224
  • #2 gst_type_find_helper_get_range_ext
    at gsttypefindhelper.c line 326
  • #3 gst_type_find_element_activate
    at gsttypefindelement.c line 961
  • #4 gst_pad_set_active
    at gstpad.c line 708
  • #5 activate_pads
    at gstelement.c line 2812
  • #6 gst_iterator_fold
    at gstiterator.c line 549
  • #7 iterator_activate_fold_with_resync
    at gstelement.c line 2843
  • #8 gst_element_pads_activate
    at gstelement.c line 2887
  • #9 gst_element_change_state_func
    at gstelement.c line 2957
  • #10 gst_type_find_element_change_state
    at gsttypefindelement.c line 1031
  • #11 gst_element_change_state
    at gstelement.c line 2728
  • #12 gst_element_set_state_func
    at gstelement.c line 2684
  • #13 gst_element_set_state
    at gstelement.c line 2585
  • #14 gst_bin_element_set_state
    at gstbin.c line 2209
  • #15 gst_bin_change_state_func
    at gstbin.c line 2518
  • #16 gst_decode_bin_change_state
    at gstdecodebin2.c line 3728
  • #17 gst_element_change_state
    at gstelement.c line 2728
  • #18 gst_element_set_state_func
    at gstelement.c line 2684
  • #19 gst_element_set_state
    at gstelement.c line 2585
  • #20 gst_bin_element_set_state
    at gstbin.c line 2209
  • #21 gst_bin_change_state_func
    at gstbin.c line 2518
  • #22 gst_pipeline_change_state
    at gstpipeline.c line 482
  • #23 gst_element_change_state
    at gstelement.c line 2728
  • #24 gst_element_continue_state
    at gstelement.c line 2411
  • #25 gst_element_change_state
    at gstelement.c line 2765
  • #26 gst_element_set_state_func
    at gstelement.c line 2684
  • #27 gst_element_set_state
    at gstelement.c line 2585
  • #28 GstMediaPlayer::ThreadFunc
    at ../platforms/media_backends/gst/gstmediaplayer.cpp line 290
  • #29 ??
    from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  • #30 start_thread
    from /lib/x86_64-linux-gnu/libpthread.so.0
  • #31 clone
    from /lib/x86_64-linux-gnu/libc.so.6
  • #32 ??

Comment 1 Philip Jägenstedt 2011-06-15 12:17:35 UTC
Created attachment 189979 [details] [review]
NULL check result of gst_type_find_peek
Comment 2 Tim-Philipp Müller 2011-06-15 17:40:12 UTC
I wonder how that happens. Something else seems wrong here, ie if it does:

  len = gst_type_find_get_length (tf);
  if (len < 34)
    return;

then peek(0, 4) must succeed, or the length reporting is broken. Any idea what's going on? Can you reproduce the issue?

The NULL checks aren't wrong of course, but we shouldn't work around bugs elsewhere IMHO.
Comment 3 Philip Jägenstedt 2011-06-16 07:54:44 UTC
I thought that was a bit odd too, but looking at the documentation of gst_type_find_get_length it claims to be "the length of the data stream", not that the data is actually available. Is the documentation incorrect? In the case where it crashed, _get_length had returned something suspiciously close to 2^16, but since I couldn't see any 16-bit integers involved I shrugged that off.

I can try reverting my fix and have a closer look inside the typefinder object when it happens again.
Comment 4 Philip Jägenstedt 2011-06-16 08:54:20 UTC
I could reproduce this yesterday twice, but it is very racy (since probably one has to have loaded only 1-3 bytes for this to happen) and I'm not having any luck today.

Can someone confirm if gst_type_find_get_length is supposed to guarantee that gst_type_find_peek cannot fail?
Comment 5 Philip Jägenstedt 2011-06-16 09:31:47 UTC
OK, so it happened again, but with another input: 2samples.wav attached to https://bugzilla.gnome.org/show_bug.cgi?id=652562

What's happening here is that our custom source is fails with GST_FLOW_UNEXPECTED in _create because the pipeline needs to be destroyed. This happens when a user leaves a page with a <video> element and is necessary, at that point we can't provide the data and need to be able to fail in _create.

Perhaps few other sources can fail in _create like this, but _create does return GstFlowReturn, so reasonably no code should assume that it succeeds.

Reopening, as it would seem that this is either a bug in typefind or a bug in the documentation of basesrc _create to say that it must always succeed.
Comment 6 Philip Jägenstedt 2011-06-17 11:35:32 UTC
It's quite clear from <https://bugzilla.gnome.org/show_bug.cgi?id=652562> and <https://bugzilla.gnome.org/show_bug.cgi?id=617733> that _create shouldn't return less data than expected in the case of GST_FLOW_OK.

However, I think that my patch is correct, because the current code assumes that the source cannot fail, finally. Clearly, it's possible for a network source to fail and just not be able to deliver more data.
Comment 7 Sebastian Dröge (slomo) 2011-06-26 13:55:38 UTC
I think the same is assumed in many other typefinders too btw. Your patch is correct though but do you want to review/patch the other typefinders too? :)
Comment 8 Tim-Philipp Müller 2011-06-26 22:40:35 UTC
> I think the same is assumed in many other typefinders too btw.

Didn't see any others.

Pushed, thanks for the patch:

 commit f3e65f1c9374df13e4fa082bc750ce94e38c58de
 Author: Philip Jägenstedt <philipj@opera.com>
 Date:   Wed Jun 15 13:51:31 2011 +0200

    typefind: NULL check in degas_type_find
    
    The length check isn't sufficient, an source might
    report the correct length, but then still fail to
    read the requested number of bytes for some reason.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=652642
Comment 9 Philip Jägenstedt 2011-06-28 09:31:01 UTC
(In reply to comment #7)
> I think the same is assumed in many other typefinders too btw. Your patch is
> correct though but do you want to review/patch the other typefinders too? :)

I did look through the code when writing the patch looking for other offenders, but like you, I didn't find anything obvious.