From 6d6122b46122ca45873383581a0eca8f616165ca Mon Sep 17 00:00:00 2001 From: sprang Date: Wed, 13 Jul 2016 06:37:09 -0700 Subject: [PATCH] Avoid race in Call destructor Don't update histograms until we're sure process threads won't call into the instance being destructed, trying to update stats. BUG=webrtc:6103 Review-Url: https://codereview.webrtc.org/2151433002 Cr-Commit-Position: refs/heads/master@{#13461} --- webrtc/call/call.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc index dfb1879a5f..51e0cceac9 100644 --- a/webrtc/call/call.cc +++ b/webrtc/call/call.cc @@ -265,8 +265,6 @@ Call::Call(const Call::Config& config) Call::~Call() { RTC_DCHECK(!remb_.InUse()); RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); - UpdateSendHistograms(); - UpdateReceiveHistograms(); RTC_CHECK(audio_send_ssrcs_.empty()); RTC_CHECK(video_send_ssrcs_.empty()); RTC_CHECK(video_send_streams_.empty()); @@ -282,6 +280,12 @@ Call::~Call() { module_process_thread_->DeRegisterModule(call_stats_.get()); module_process_thread_->Stop(); call_stats_->DeregisterStatsObserver(congestion_controller_.get()); + + // Only update histograms after process threads have been shut down, so that + // they won't try to concurrently update stats. + UpdateSendHistograms(); + UpdateReceiveHistograms(); + Trace::ReturnTrace(); }