From 5314e859262c03e8c212fee53245e91851c1e5cc Mon Sep 17 00:00:00 2001 From: "sprang@webrtc.org" Date: Mon, 27 Jan 2014 13:20:36 +0000 Subject: [PATCH] Race condition in RTPSender::UpdateRtpStats The ssrc should not be access directly from the ssrc_ field, without holding the send_critsect_ lock. A better way is to just use the SSRC() getter method. BUG= R=pbos@webrtc.org, stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7539006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5439 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/rtp_rtcp/source/rtp_sender.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index fd320324b8..0929fd9675 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -842,15 +842,16 @@ void RTPSender::UpdateRtpStats(const uint8_t* buffer, const RTPHeader& header, bool is_rtx, bool is_retransmit) { - CriticalSectionScoped lock(statistics_crit_.get()); StreamDataCounters* counters; - uint32_t ssrc; + // Get ssrc before taking statistics_crit_ to avoid possible deadlock. + uint32_t ssrc = SSRC(); + + CriticalSectionScoped lock(statistics_crit_.get()); if (is_rtx) { counters = &rtx_rtp_stats_; ssrc = ssrc_rtx_; } else { counters = &rtp_stats_; - ssrc = ssrc_; } bitrate_sent_.Update(size);