<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>164928</bug_id>
          
          <creation_ts>2016-11-18 09:20:16 -0800</creation_ts>
          <short_desc>[GStreamer] Crash in WebCore::HTMLMediaElement::removeAudioTrack</short_desc>
          <delta_ts>2018-02-20 10:51:09 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=1369960</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>calvaris</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>pnormand</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1252697</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-11-18 09:20:16 -0800</bug_when>
    <thetext>Web process crash in WebCore::HTMLMediaElement::removeAudioTrack:

Truncated backtrace:
Thread no. 1 (10 frames)
 #0 WTF::RefPtr&lt;WebCore::AudioTrackList&gt;::operator-&gt; at /usr/src/debug/webkitgtk-2.12.3/Source/WTF/wtf/RefPtr.h:69
 #1 WebCore::HTMLMediaElement::removeAudioTrack at /usr/src/debug/webkitgtk-2.12.3/Source/WebCore/html/HTMLMediaElement.cpp:3605
 #2 WebCore::MediaPlayer::removeAudioTrack at /usr/src/debug/webkitgtk-2.12.3/Source/WebCore/platform/graphics/MediaPlayer.cpp:1253
 #3 WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio at /usr/src/debug/webkitgtk-2.12.3/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:698
 #4 WebCore::MediaPlayerPrivateGStreamer::&lt;lambda()&gt;::operator() at /usr/src/debug/webkitgtk-2.12.3/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:665
 #5 WebCore::MainThreadNotifier&lt;WebCore::MediaPlayerPrivateGStreamerBase::MainThreadNotification&gt;::notify&lt;WebCore::MediaPlayerPrivateGStreamer::audioChangedCallback(WebCore::MediaPlayerPrivateGStreamer*)::&lt;lambda()&gt; &gt; at /usr/src/debug/webkitgtk-2.12.3/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h:42
 #6 WebCore::MediaPlayerPrivateGStreamer::audioChangedCallback at /usr/src/debug/webkitgtk-2.12.3/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:665
 #7 _g_closure_invoke_va at gclosure.c:867
 #10 g_cclosure_marshal_VOID__OBJECTv at gmarshal.c:2102
 #11 _g_closure_invoke_va at gclosure.c:867

We have seven reports of this crash. Full backtrace on the downstream bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1256294</commentid>
    <comment_count>1</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2016-12-05 07:00:01 -0800</bug_when>
    <thetext>Steps to reproduce?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1256295</commentid>
    <comment_count>2</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2016-12-05 07:05:49 -0800</bug_when>
    <thetext>Looks like a use-after-free, the track is removed from the list and then reused, not sure how that is supposed to work :)

https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp#L727</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1272850</commentid>
    <comment_count>3</comment_count>
    <who name="Xabier Rodríguez Calvar">calvaris</who>
    <bug_when>2017-02-03 02:28:50 -0800</bug_when>
    <thetext>A use case for testing would be interesting</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1272867</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-02-03 04:05:56 -0800</bug_when>
    <thetext>Normally users don&apos;t know what causes a crash; this case is no exception.

Note: we&apos;re still at only seven reports, so nobody has hit this in Fedora in the past two months.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400769</commentid>
    <comment_count>5</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2018-02-20 07:56:17 -0800</bug_when>
    <thetext>Looking at the stack-trace in the downstream bug, it refers to code that was removed in bug 137552 ... So I&apos;ll close this issue because the crash should no longer happen. Please re-open otherwise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400824</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-02-20 10:26:01 -0800</bug_when>
    <thetext>(In reply to Philippe Normand from comment #5)
&gt; Looking at the stack-trace in the downstream bug, it refers to code that was
&gt; removed in bug 137552 ... So I&apos;ll close this issue because the crash should
&gt; no longer happen. Please re-open otherwise.

The timeline is not right. This crash was reported in late 2016. That bug was closed in 2014. Sometimes frames get omitted from the stack trace; likely the crash is really inside mediaPlayerDidRemoveAudioTrack. The MediaPlayerClient is surely HTMLMediaElement.

I assume the crash must have been happening here:

void HTMLMediaElement::removeAudioTrack(AudioTrack&amp; track)
{
    m_audioTracks-&gt;remove(track); // &lt;---
    track.clearClient();
}

But I agree the current code does not match up. I&apos;m not sure when it changed; trac doesn&apos;t allow blaming HTMLMediaElement because it is too big, and GitHub just times out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400836</commentid>
    <comment_count>7</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2018-02-20 10:51:09 -0800</bug_when>
    <thetext>Could the fix not be part of the stable release that was crashing?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>