From ba09f79ba31c543d0dcf3a6d824992685087005a Mon Sep 17 00:00:00 2001 From: oprypin Date: Mon, 4 Sep 2017 08:32:43 -0700 Subject: [PATCH] Make UBSan warnings fatal and fix the existing ones The warnings were (all signed integer overflow): webrtc/common_audio/signal_processing/levinson_durbin.c:46:25 12 * 268435456 cannot be represented in type 'int' webrtc/modules/audio_processing/aecm/aecm_core.cc:930:69 522240 * 6115 cannot be represented in type 'int' webrtc/modules/audio_processing/aecm/aecm_core_c.cc:455:36 72293096 * 50 cannot be represented in type 'int' webrtc/modules/pacing/alr_detector.cc:70:48 1000000000 * 65 cannot be represented in type 'int' webrtc/modules/rtp_rtcp/source/rtp_sender.cc:947:20 1929277286 + 321546521 cannot be represented in type 'int' BUG=webrtc:8195 Review-Url: https://codereview.webrtc.org/3005003002 Cr-Commit-Position: refs/heads/master@{#19670} --- tools_webrtc/mb/mb_config.pyl | 4 ++-- tools_webrtc/ubsan/blacklist.txt | 5 +++++ webrtc/modules/audio_processing/aecm/aecm_core.cc | 5 +++-- webrtc/modules/pacing/alr_detector.cc | 5 +++-- webrtc/modules/rtp_rtcp/source/rtp_sender.cc | 6 +++--- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl index 35b249c01b..a396e953dc 100644 --- a/tools_webrtc/mb/mb_config.pyl +++ b/tools_webrtc/mb/mb_config.pyl @@ -461,11 +461,11 @@ }, 'ubsan': { - 'gn_args': 'is_ubsan=true', + 'gn_args': 'is_ubsan=true is_ubsan_no_recover=true', }, 'ubsan_vptr': { - 'gn_args': 'is_ubsan_vptr=true', + 'gn_args': 'is_ubsan_vptr=true is_ubsan_no_recover=true', }, 'win_fastlink': { diff --git a/tools_webrtc/ubsan/blacklist.txt b/tools_webrtc/ubsan/blacklist.txt index 403c86645a..a65b1600c4 100644 --- a/tools_webrtc/ubsan/blacklist.txt +++ b/tools_webrtc/ubsan/blacklist.txt @@ -22,6 +22,10 @@ src:*/usr/* # https://bugs.chromium.org/p/webrtc/issues/detail?id=5513 fun:*FilterBanksTest*CalculateResidualEnergyTester* +############################################################################# +# https://bugs.chromium.org/p/webrtc/issues/detail?id=8200 +fun:*WebRtcAecm_ProcessBlock* + ############################################################################# # Ignore errors in common_audio. # https://bugs.chromium.org/p/webrtc/issues/detail?id=5486 @@ -30,4 +34,5 @@ src:*/webrtc/common_audio/signal_processing/resample_by_2_internal.c fun:*WebRtcSpl_AddSatW32* fun:*WebRtcSpl_SubSatW32* fun:*WebRtcSpl_DivW32HiLow* +fun:*WebRtcSpl_LevinsonDurbin* fun:*GmmProbability* diff --git a/webrtc/modules/audio_processing/aecm/aecm_core.cc b/webrtc/modules/audio_processing/aecm/aecm_core.cc index 0e0b6ffbfd..580915483d 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core.cc +++ b/webrtc/modules/audio_processing/aecm/aecm_core.cc @@ -24,6 +24,7 @@ extern "C" { } #include "webrtc/rtc_base/checks.h" +#include "webrtc/rtc_base/safe_conversions.h" #include "webrtc/typedefs.h" #ifdef AEC_DEBUG @@ -927,8 +928,8 @@ void WebRtcAecm_UpdateChannel(AecmCore* aecm, { // We need to shift down before multiplication shiftChFar = 32 - zerosCh - zerosFar; - tmpU32no1 = (aecm->channelAdapt32[i] >> shiftChFar) * - far_spectrum[i]; + tmpU32no1 = rtc::dchecked_cast( + aecm->channelAdapt32[i] >> shiftChFar) * far_spectrum[i]; } // Determine Q-domain of numerator zerosNum = WebRtcSpl_NormU32(tmpU32no1); diff --git a/webrtc/modules/pacing/alr_detector.cc b/webrtc/modules/pacing/alr_detector.cc index 7d62b21251..68732105c1 100644 --- a/webrtc/modules/pacing/alr_detector.cc +++ b/webrtc/modules/pacing/alr_detector.cc @@ -67,8 +67,9 @@ void AlrDetector::OnBytesSent(size_t bytes_sent, int64_t delta_time_ms) { void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { RTC_DCHECK(bitrate_bps); - alr_budget_.set_target_rate_kbps(bitrate_bps * bandwidth_usage_percent_ / - (1000 * 100)); + const auto target_rate_kbps = int64_t{bitrate_bps} * + bandwidth_usage_percent_ / (1000 * 100); + alr_budget_.set_target_rate_kbps(rtc::dchecked_cast(target_rate_kbps)); } rtc::Optional AlrDetector::GetApplicationLimitedRegionStartTime() diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index 8608759594..6fd7600cbb 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -936,7 +936,7 @@ void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) { return; uint32_t ssrc; - int avg_delay_ms = 0; + int64_t avg_delay_ms = 0; int max_delay_ms = 0; { rtc::CritScope lock(&send_critsect_); @@ -962,8 +962,8 @@ void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) { return; avg_delay_ms = (avg_delay_ms + num_delays / 2) / num_delays; } - send_side_delay_observer_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, - ssrc); + send_side_delay_observer_->SendSideDelayUpdated( + rtc::dchecked_cast(avg_delay_ms), max_delay_ms, ssrc); } void RTPSender::UpdateOnSendPacket(int packet_id,