Commit cb95c0d19d for aom
commit cb95c0d19dc6114050e12fe2a091fb33dd99251d
Author: Wan-Teh Chang <wtc@google.com>
Date: Wed Jul 15 14:27:08 2026 -0700
Poison memory in AV1Convolve2DTest::TestConvolve()
Call ASAN_POISON_MEMORY_REGION() in AV1Convolve2DTest::TestConvolve() to
help detect overread at the end of the src buffer in the
av1_convolve_2d_sr_*() functions.
Change-Id: I12eeb026b8c2222269619b3d5305f6a14b1102ad
diff --git a/test/av1_convolve_test.cc b/test/av1_convolve_test.cc
index ea40a26d38..9d4827162e 100644
--- a/test/av1_convolve_test.cc
+++ b/test/av1_convolve_test.cc
@@ -17,6 +17,7 @@
#include "config/av1_rtcd.h"
#include "config/aom_dsp_rtcd.h"
#include "aom_ports/aom_timer.h"
+#include "aom_ports/sanitizer.h"
#include "gtest/gtest.h"
#include "test/acm_random.h"
@@ -1290,18 +1291,33 @@ class AV1Convolve2DTest : public AV1ConvolveTest<convolve_2d_func> {
const InterpFilterParams *filter_params_y =
av1_get_interp_filter_params_with_block_size(v_f, height);
const uint8_t *input = FirstRandomInput8(GetParam());
+ const int input_stride = width;
+ // The following variables come from av1_convolve_2d_sr_c().
+ const int im_h = height + filter_params_y->taps - 1;
+ const int fo_vert = filter_params_y->taps / 2 - 1;
+ const int fo_horiz = filter_params_x->taps / 2 - 1;
+ // av1_convolve_2d_sr_sse2() overreads 7 bytes. av1_convolve_2d_sr_avx2()
+ // overreads 5 bytes. av1_convolve_2d_sr_avx512() overreads 8 bytes.
+ // av1_convolve_2d_sr_neon() overreads 2 bytes.
+ // av1_convolve_2d_sr_neon_dotprod() overreads 7 bytes.
+ const int kOverread = 8;
+ const int input_size = -fo_vert * input_stride + (im_h - 1) * input_stride +
+ width - 1 - fo_horiz + filter_params_x->taps +
+ kOverread;
+ ASAN_POISON_MEMORY_REGION(input + input_size, 16);
DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
ConvolveParams conv_params1 =
get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
- av1_convolve_2d_sr_c(input, width, reference, kOutputStride, width, height,
- filter_params_x, filter_params_y, sub_x, sub_y,
+ av1_convolve_2d_sr_c(input, input_stride, reference, kOutputStride, width,
+ height, filter_params_x, filter_params_y, sub_x, sub_y,
&conv_params1);
DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
ConvolveParams conv_params2 =
get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
- GetParam().TestFunction()(input, width, test, kOutputStride, width, height,
- filter_params_x, filter_params_y, sub_x, sub_y,
- &conv_params2);
+ GetParam().TestFunction()(input, input_stride, test, kOutputStride, width,
+ height, filter_params_x, filter_params_y, sub_x,
+ sub_y, &conv_params2);
+ ASAN_UNPOISON_MEMORY_REGION(input + input_size, 16);
AssertOutputBufferEq(reference, test, width, height);
}