Ignore some UBSan errors
They proved to be too difficult to fix properly, so we revert the saturation fixes that were done in https://codereview.webrtc.org/2729573002 and https://codereview.webrtc.org/2746903002, and ignore them instead. BUG=webrtc:7307, chromium:709364, chromium:693868 Review-Url: https://codereview.webrtc.org/2809483002 Cr-Commit-Position: refs/heads/master@{#17612}
This commit is contained in:
@ -63,11 +63,6 @@ static __inline int WebRtcSpl_CountLeadingZeros64(uint64_t n) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline int32_t WebRtcSpl_SatW64ToW32(int64_t x) {
|
|
||||||
int32_t x32 = (int32_t)x;
|
|
||||||
return x32 == x ? x32 : x < 0 ? INT32_MIN : INT32_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WEBRTC_ARCH_ARM_V7
|
#ifdef WEBRTC_ARCH_ARM_V7
|
||||||
#include "webrtc/common_audio/signal_processing/include/spl_inl_armv7.h"
|
#include "webrtc/common_audio/signal_processing/include/spl_inl_armv7.h"
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include "lpc_tables.h"
|
#include "lpc_tables.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "signal_processing_library.h"
|
#include "signal_processing_library.h"
|
||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/sanitizer.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Eenumerations for arguments to functions WebRtcIsacfix_MatrixProduct1()
|
* Eenumerations for arguments to functions WebRtcIsacfix_MatrixProduct1()
|
||||||
@ -189,6 +189,22 @@ static void CalcCorrelation(int32_t *PSpecQ12, int32_t *CorrQ7)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some arithmetic operations that are allowed to overflow. (It's still
|
||||||
|
// undefined behavior, so not a good idea; this just makes UBSan ignore the
|
||||||
|
// violations, so that our old code can continue to do what it's always been
|
||||||
|
// doing.)
|
||||||
|
static inline int32_t OverflowingMulS16S32ToS32(int16_t a, int32_t b)
|
||||||
|
RTC_NO_SANITIZE("signed-integer-overflow") {
|
||||||
|
return a * b;
|
||||||
|
}
|
||||||
|
static inline int32_t OverflowingAddS32S32ToS32(int32_t a, int32_t b)
|
||||||
|
RTC_NO_SANITIZE("signed-integer-overflow") {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
static inline int32_t OverflowingSubS32S32ToS32(int32_t a, int32_t b)
|
||||||
|
RTC_NO_SANITIZE("signed-integer-overflow") {
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
|
||||||
/* compute inverse AR power spectrum */
|
/* compute inverse AR power spectrum */
|
||||||
static void CalcInvArSpec(const int16_t *ARCoefQ12,
|
static void CalcInvArSpec(const int16_t *ARCoefQ12,
|
||||||
@ -231,11 +247,11 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
|
|||||||
CurveQ16[n] = sum;
|
CurveQ16[n] = sum;
|
||||||
|
|
||||||
for (k = 1; k < AR_ORDER; k += 2) {
|
for (k = 1; k < AR_ORDER; k += 2) {
|
||||||
for (n = 0; n < FRAMESAMPLES/8; n++) {
|
for (n = 0; n < FRAMESAMPLES/8; n++)
|
||||||
const int64_t p =
|
CurveQ16[n] +=
|
||||||
(WebRtcIsacfix_kCos[k][n] * (int64_t)CorrQ11[k + 1] + 2) >> 2;
|
(OverflowingMulS16S32ToS32(WebRtcIsacfix_kCos[k][n], CorrQ11[k + 1]) +
|
||||||
CurveQ16[n] += WebRtcSpl_SatW64ToW32(p);
|
2) >>
|
||||||
}
|
2;
|
||||||
}
|
}
|
||||||
|
|
||||||
CS_ptrQ9 = WebRtcIsacfix_kCos[0];
|
CS_ptrQ9 = WebRtcIsacfix_kCos[0];
|
||||||
@ -261,8 +277,8 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
|
|||||||
for (k=0; k<FRAMESAMPLES/8; k++) {
|
for (k=0; k<FRAMESAMPLES/8; k++) {
|
||||||
int32_t diff_q16 = diffQ16[k] * (1 << shftVal);
|
int32_t diff_q16 = diffQ16[k] * (1 << shftVal);
|
||||||
CurveQ16[FRAMESAMPLES / 4 - 1 - k] =
|
CurveQ16[FRAMESAMPLES / 4 - 1 - k] =
|
||||||
WebRtcSpl_SubSatW32(CurveQ16[k], diff_q16);
|
OverflowingSubS32S32ToS32(CurveQ16[k], diff_q16);
|
||||||
CurveQ16[k] = WebRtcSpl_AddSatW32(CurveQ16[k], diff_q16);
|
CurveQ16[k] = OverflowingAddS32S32ToS32(CurveQ16[k], diff_q16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,10 +513,8 @@ int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
|
|||||||
{
|
{
|
||||||
for (k = 0; k < FRAMESAMPLES; k += 4)
|
for (k = 0; k < FRAMESAMPLES; k += 4)
|
||||||
{
|
{
|
||||||
gainQ10 = WebRtcSpl_DivW32W16ResW16(
|
gainQ10 = WebRtcSpl_DivW32W16ResW16(30 << 10,
|
||||||
30 << 10, (int16_t)((uint32_t)(WebRtcSpl_AddSatW32(
|
(int16_t)((uint32_t)(invARSpec2_Q16[k >> 2] + 2195456) >> 16));
|
||||||
invARSpec2_Q16[k >> 2], 2195456)) >>
|
|
||||||
16));
|
|
||||||
*frQ7++ = (int16_t)((data[k] * gainQ10 + 512) >> 10);
|
*frQ7++ = (int16_t)((data[k] * gainQ10 + 512) >> 10);
|
||||||
*fiQ7++ = (int16_t)((data[k + 1] * gainQ10 + 512) >> 10);
|
*fiQ7++ = (int16_t)((data[k + 1] * gainQ10 + 512) >> 10);
|
||||||
*frQ7++ = (int16_t)((data[k + 2] * gainQ10 + 512) >> 10);
|
*frQ7++ = (int16_t)((data[k + 2] * gainQ10 + 512) >> 10);
|
||||||
@ -511,10 +525,8 @@ int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
|
|||||||
{
|
{
|
||||||
for (k = 0; k < FRAMESAMPLES; k += 4)
|
for (k = 0; k < FRAMESAMPLES; k += 4)
|
||||||
{
|
{
|
||||||
gainQ10 = WebRtcSpl_DivW32W16ResW16(
|
gainQ10 = WebRtcSpl_DivW32W16ResW16(36 << 10,
|
||||||
36 << 10, (int16_t)((uint32_t)(WebRtcSpl_AddSatW32(
|
(int16_t)((uint32_t)(invARSpec2_Q16[k >> 2] + 2654208) >> 16));
|
||||||
invARSpec2_Q16[k >> 2], 2654208)) >>
|
|
||||||
16));
|
|
||||||
*frQ7++ = (int16_t)((data[k] * gainQ10 + 512) >> 10);
|
*frQ7++ = (int16_t)((data[k] * gainQ10 + 512) >> 10);
|
||||||
*fiQ7++ = (int16_t)((data[k + 1] * gainQ10 + 512) >> 10);
|
*fiQ7++ = (int16_t)((data[k + 1] * gainQ10 + 512) >> 10);
|
||||||
*frQ7++ = (int16_t)((data[k + 2] * gainQ10 + 512) >> 10);
|
*frQ7++ = (int16_t)((data[k + 2] * gainQ10 + 512) >> 10);
|
||||||
|
|||||||
Reference in New Issue
Block a user