From 3f670e07fe9620d3b3c239067d554b7d545f0838 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Tue, 10 Oct 2017 11:18:49 +0200 Subject: [PATCH] Fix potential crash bug in debug builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call to |interframe_delay_max_moving_.Add()| below depends on |now| non decreasing in consequtive calls. However, if two threads are competing for the lock it may happen that current thread calculates |now| before the other thread, yet it will get the lock later. This will result in decreasing local time in consecutive calls and trigger a DCHECK. The same also applies to |timing_frame_info_counter_|. Bug: none Change-Id: I3376d88d4448c2c105e9227a445b11cd6ba8d341 Reviewed-on: https://webrtc-review.googlesource.com/7861 Commit-Queue: Ilya Nikolaevskiy Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/master@{#20217} --- video/receive_statistics_proxy.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index 858f451da1..6e61032fad 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -564,8 +564,8 @@ void ReceiveStatisticsProxy::OnFrameBufferTimingsUpdated( void ReceiveStatisticsProxy::OnTimingFrameInfoUpdated( const TimingFrameInfo& info) { - int64_t now_ms = clock_->TimeInMilliseconds(); rtc::CritScope lock(&crit_); + int64_t now_ms = clock_->TimeInMilliseconds(); timing_frame_info_counter_.Add(info, now_ms); } @@ -628,10 +628,10 @@ void ReceiveStatisticsProxy::DataCountersUpdated( void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional qp, VideoContentType content_type) { - uint64_t now = clock_->TimeInMilliseconds(); - rtc::CritScope lock(&crit_); + uint64_t now = clock_->TimeInMilliseconds(); + ContentSpecificStats* content_specific_stats = &content_specific_stats_[content_type]; ++stats_.frames_decoded;