setRemoteDescription crashing browser with previously valid SDP
Reported by
oshiro.h...@gmail.com,
Sep 27 2017
|
||||||||
Issue description
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Steps to reproduce the problem:
1. Open Browser console and execute steps provided in the attached file:
2. pc = new RTCPeerConnection();
3. v = {"type":"offer","sdp":"v=0\r\no=- 1923518516 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS mixedmslabel\r\na=group:BUNDLE audio video data\r\nm=audio 10000 RTP/SAVPF 111 103 104 0 8 106 105 13 126\r\nc=IN IP4 127.0.0.2\r\na=rtpmap:111 opus/48000/2\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:126 telephone-event/8000\r\na=fmtp:111 minptime=10\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=mid:audio\r\na=sendrecv\r\na=ice-ufrag:crlf01br2gd237\r\na=ice-pwd:2em6f7c26p9b4ckspknjtebil1\r\na=fingerprint:sha-1 96:CE:2C:E1:3A:7F:A9:D7:F2:78:D5:00:C9:67:5A:41:32:2B:30:EC\r\na=candidate:1 1 udp 2130706431 127.0.0.1 10000 typ host generation 0\r\na=candidate:2 1 udp 2130706431 127.0.0.2 10000 typ host generation 0\r\na=candidate:3 1 udp 1677724415 127.0.0.2 10000 typ srflx raddr 127.0.0.1 rport 10000 generation 0\r\na=ssrc:3046886211 cname:mixed\r\na=ssrc:3046886211 label:mixedlabelaudio0\r\na=ssrc:3046886211 msid:mixedmslabel mixedlabelaudio0\r\na=ssrc:3046886211 mslabel:mixedmslabel\r\na=rtcp-mux\r\nm=video 10000 RTP/SAVPF 100 116 117\r\nc=IN IP4 127.0.0.2\r\nb=AS:750\r\na=rtpmap:100 VP8/90000\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 ulpfec/90000\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=rtcp-fb:100 goog-remb\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=mid:video\r\na=sendrecv\r\na=ice-ufrag:crlf01br2gd237\r\na=ice-pwd:2em6f7c26p9b4ckspknjtebil1\r\na=fingerprint:sha-1 96:CE:2C:E1:3A:7F:A9:D7:F2:78:D5:00:C9:67:5A:41:32:2B:30:EC\r\na=candidate:1 1 udp 2130706431 127.0.0.1 10000 typ host generation 0\r\na=candidate:2 1 udp 2130706431 127.0.0.2 10000 typ host generation 0\r\na=candidate:3 1 udp 1677724415 127.0.0.2 10000 typ srflx raddr 127.0.0.1 rport 10000 generation 0\r\na=ssrc:3046886211 cname:mixed\r\na=ssrc:3046886211 label:mixedlabelaudio0\r\na=ssrc:3046886211 msid:mixedmslabel mixedlabelaudio0\r\na=ssrc:3046886211 mslabel:mixedmslabel\r\na=rtcp-mux\r\nm=application 10000 DTLS/SCTP 5000\r\nc=IN IP4 127.0.0.2\r\na=mid:data\r\na=ice-ufrag:crlf01br2gd237\r\na=ice-pwd:2em6f7c26p9b4ckspknjtebil1\r\na=fingerprint:sha-1 96:CE:2C:E1:3A:7F:A9:D7:F2:78:D5:00:C9:67:5A:41:32:2B:30:EC\r\na=candidate:1 1 udp 2130706431 127.0.0.1 10000 typ host generation 0\r\na=candidate:2 1 udp 2130706431 127.0.0.2 10000 typ host generation 0\r\na=candidate:3 1 udp 1677724415 127.0.0.2 10000 typ srflx raddr 127.0.0.1 rport 10000 generation 0\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"};
4. pc.setRemoteDescription(v);
What is the expected behavior?
The last command would return a Promise with no error
What went wrong?
The browser crashes: "Aw, Snap!"
Did this work before? Yes 60
Does this work in other browsers? N/A
Chrome version: 61.0.3163.100 Channel: stable
OS Version:
Flash Version: Shockwave Flash 27.0 r0
The same steps goes well with previous version of Google Chrome (tested from 56 to 60)
,
Sep 29 2017
Oh snap, I'll take a look on Monday!
,
Sep 29 2017
,
Sep 29 2017
Here's a jsfiddle: https://jsfiddle.net/xn4fpywr Seems to be related to the video and audio tracks having the same ID. [1:20:0929/144137.577861:FATAL:webrtc_media_stream_track_adapter_map.cc(23)] Check failed: map_->main_thread_->BelongsToCurrentThread(). #0 0x7f88c1ab805d base::debug::StackTrace::StackTrace() #1 0x7f88c1ab642c base::debug::StackTrace::StackTrace() #2 0x7f88c1b4792a logging::LogMessage::~LogMessage() #3 0x7f88bcc9feaa content::WebRtcMediaStreamTrackAdapterMap::AdapterRef::~AdapterRef() #4 0x7f88bcc8ca14 std::__1::pair<>::~pair() #5 0x7f88bcc885b6 content::WebRtcMediaStreamAdapter::GetAdapterRefMapFromWebRtcStream() #6 0x7f88bcc8a6e6 content::RemoteWebRtcMediaStreamAdapter::RemoteWebRtcMediaStreamAdapter() #7 0x7f88bcc8c8ef _ZN4base10MakeUniqueIN7content30RemoteWebRtcMediaStreamAdapterEJ13scoped_refptrINS_22SingleThreadTaskRunnerEES3_INS1_32WebRtcMediaStreamTrackAdapterMapEES3_IN6webrtc20MediaStreamInterfaceEEEEEDTclsr3stdE11make_uniqueIT_Espclsr3stdE7forwardIT0_Efp_EEEDpOSC_ #8 0x7f88bcc8759f content::WebRtcMediaStreamAdapter::CreateRemoteStreamAdapter() #9 0x7f88bcc91a85 content::WebRtcMediaStreamAdapterMap::GetOrCreateRemoteStreamAdapter() #10 0x7f88bcbfb0d0 content::RTCPeerConnectionHandler::Observer::OnAddStream() #11 0x7f88bdc9e7f9 webrtc::PeerConnection::SetRemoteDescription()
,
Oct 2 2017
It makes sense my change would have caused this, but I would have thought https://chromium-review.googlesource.com/c/chromium/src/+/666923 should fix it. That is not the case, its still crashing on tip of tree. I need to investigate further. This must not be a common use case considering how long it took until it was detected, but it would be nice to fix this for 62 stable, if possible to merge - there as been a lot of changes in these parts of the code recently.
,
Oct 2 2017
Nevermind, I have fixed allowing same IDs for streams and tracks removed and re-added, but the thread check is a different problem and audio and video tracks having the same ID is something different too. Is that even allowed?
,
Oct 3 2017
I can't find anything that disallows it, but may be a good question for the mailing list.
,
Oct 3 2017
Related issue: https://bugs.chromium.org/p/webrtc/issues/detail?id=5625
,
Oct 3 2017
Here's a tweak to that fiddle so you have to press "Run" before it crashes: https://jsfiddle.net/1wkzhszp/
,
Oct 3 2017
There are AdapterRefs created for track adapters on the webrtc signaling threads. These need to be destroyed on the main thread, which they normally are because the RemoteWebRtcMediaStreamAdapter that takes ownership of the AdapterRefs is destroyed on the main thread. The problem is this line: https://cs.chromium.org/chromium/src/content/renderer/media/webrtc/webrtc_media_stream_adapter.cc?type=cs&sq=package:chromium&l=55 There is an ID -> AdapterRef map assuming IDs are unique. The second "insert" does not insert the element because there is already a mapping, and the AdapterRef we tried to insert is instead destroyed here, on the webrtc signaling thread.
,
Oct 3 2017
1. Audio and video tracks have different SSRCs and IDs: https://jsfiddle.net/n5e0e6oc/ This works as expected. Promise is resolved. 2. Audio and video have different IDs but the same SSRC: https://jsfiddle.net/v117d6sz/ The promise is resolved, but it shouldn't be. Tracks shouldn't be able to have the same SSRC. 3. Audio and video have different SSRCs but the same ID: https://jsfiddle.net/n0xbs31k/ Whether this should be resolved or rejected is debatable, but it crashes. It shouldn't. 4. Combination of 2+3: Audio and video have same SSRC and ID: https://jsfiddle.net/jkdewtd3/ This crashes for the same reason as 3). It should be rejected for the same reason as 2).
,
Oct 3 2017
The bug is reported with case 4). oshiro.hugo@gmail.com: See comment #11, you're doing something wrong by having the same SSRC for both tracks. Of course we still need to fix this bug so it doesn't crash, but FYI when all bugs are fixed your SDP will be rejected.
,
Oct 3 2017
WRT 2) I filed webrtc repo issue https://crbug.com/webrtc/8328. WRT 3) I will try to fix this tomorrow, gotta run.
,
Oct 3 2017
Thanks for the effort and clarifications, hbos@chromium.org. I'll solve things here on my side.
,
Oct 4 2017
,
Oct 4 2017
With https://chromium-review.googlesource.com/c/chromium/src/+/700263 I fixed the problem in the chromium layers, but it turns out that there are assumptions in the webrtc layer too. For example, FindReceiverForTrack looks up receiver by track ID, which in this case is not unique. With my CL it still crashes when I run 3) because it gets the wrong receiver from the webrtc layer. I think (at least for now) the appropriate action is to reject the promise. I filed: https://crbug.com/webrtc/8339
,
Oct 5 2017
,
Oct 9 2017
hbos@ Gentle ping! Since this issue is marked as RB-Stable for M-62 could you please let us know is there any latest update available on this issue? Thanks!
,
Oct 9 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/db00702e9e2ed80c69ddbfe4a234eefacdc10e35 commit db00702e9e2ed80c69ddbfe4a234eefacdc10e35 Author: Henrik Boström <hbos@chromium.org> Date: Mon Oct 09 17:35:22 2017 Handle streams containing multiple tracks with the same ID. Using WebMediaStreamTrack::UniqueId() and webrtc::MediaStreamTrackInterface* as unique identifiers for tracks, instead of assuming their string ID is unique. A similar fix was previously made for the WebRtcMediaStream[Track]AdapterMaps (mapping *all* streams and *all* tracks), but the assumption about track IDs being unique was still made on a per-stream basis. This CL removes that assumption and adds test coverage. Bug: 769470 Change-Id: If2c13ea44856e4d25fb8579e4dee9eb595d29b9f Reviewed-on: https://chromium-review.googlesource.com/700263 Reviewed-by: Guido Urdaneta <guidou@chromium.org> Commit-Queue: Henrik Boström <hbos@chromium.org> Cr-Commit-Position: refs/heads/master@{#507400} [modify] https://crrev.com/db00702e9e2ed80c69ddbfe4a234eefacdc10e35/content/renderer/media/media_stream_video_track.cc [modify] https://crrev.com/db00702e9e2ed80c69ddbfe4a234eefacdc10e35/content/renderer/media/media_stream_video_track.h [modify] https://crrev.com/db00702e9e2ed80c69ddbfe4a234eefacdc10e35/content/renderer/media/webrtc/webrtc_media_stream_adapter.cc [modify] https://crrev.com/db00702e9e2ed80c69ddbfe4a234eefacdc10e35/content/renderer/media/webrtc/webrtc_media_stream_adapter.h [modify] https://crrev.com/db00702e9e2ed80c69ddbfe4a234eefacdc10e35/content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc
,
Oct 10 2017
hbos@, thank you for the fix. Unfortunately we don't have latest canary with the above fix (Due to crbug/773185) to verify, however we will do it on tonight's Canary. Please plan to request a merge to M62 (Branch: 3202)if you think the fix is really critical.
,
Oct 10 2017
Unfortunately, the above CL only fixes half of the problem. There's another assumption in third_party/webrtc, see https://crbug.com/webrtc/8339. It will still crash but the stack trace will be different. I don't think this is a release blocker or that we should merge (even when it's fully fixed), lowering the priority. I'll take another look when I have time. |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by krajshree@chromium.org
, Sep 29 2017Labels: -Pri-2 hasbisect-per-revision ReleaseBlock-Stable M-61 Needs-Triage-M61 OS-Mac OS-Windows Pri-1
Owner: hbos@chromium.org
Status: Assigned (was: Unconfirmed)