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}
diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl
index 35b249c..a396e95 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 403c866..a65b160 100644
--- a/tools_webrtc/ubsan/blacklist.txt
+++ b/tools_webrtc/ubsan/blacklist.txt
@@ -23,6 +23,10 @@
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
src:*/webrtc/common_audio/signal_processing/signal_processing_unittest.cc
@@ -30,4 +34,5 @@
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 0e0b6ff..5809154 100644
--- a/webrtc/modules/audio_processing/aecm/aecm_core.cc
+++ b/webrtc/modules/audio_processing/aecm/aecm_core.cc
@@ -24,6 +24,7 @@
}
#include "webrtc/rtc_base/checks.h"
+#include "webrtc/rtc_base/safe_conversions.h"
#include "webrtc/typedefs.h"
#ifdef AEC_DEBUG
@@ -927,8 +928,8 @@
{
// We need to shift down before multiplication
shiftChFar = 32 - zerosCh - zerosFar;
- tmpU32no1 = (aecm->channelAdapt32[i] >> shiftChFar) *
- far_spectrum[i];
+ tmpU32no1 = rtc::dchecked_cast<uint32_t>(
+ 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 7d62b21..6873210 100644
--- a/webrtc/modules/pacing/alr_detector.cc
+++ b/webrtc/modules/pacing/alr_detector.cc
@@ -67,8 +67,9 @@
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<int>(target_rate_kbps));
}
rtc::Optional<int64_t> AlrDetector::GetApplicationLimitedRegionStartTime()
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
index 8608759..6fd7600 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
@@ -936,7 +936,7 @@
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 @@
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<int>(avg_delay_ms), max_delay_ms, ssrc);
}
void RTPSender::UpdateOnSendPacket(int packet_id,