From 584b552ed5d34592da4459a616e22301ecf8fd79 Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Wed, 16 Mar 2022 22:01:54 +0800 Subject: [PATCH] fix potential asan error for string tests (#4279) close pingcap/tiflash#4280 --- .../tests/gtest_strings_simd_consistency.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dbms/src/Functions/tests/gtest_strings_simd_consistency.cpp b/dbms/src/Functions/tests/gtest_strings_simd_consistency.cpp index 7f04f3ee68d..92fc79eaad2 100644 --- a/dbms/src/Functions/tests/gtest_strings_simd_consistency.cpp +++ b/dbms/src/Functions/tests/gtest_strings_simd_consistency.cpp @@ -296,9 +296,9 @@ TEST(StringsLowerUpperAscii, Random) std::random_device device; auto seed = device(); std::cout << "seeded with: " << seed << std::endl; - std::vector data(limit); - std::vector res_new(limit); - std::vector res_old(limit); + std::vector data(limit + 1); + std::vector res_new(limit + 1, 0); + std::vector res_old(limit + 1, 0); std::default_random_engine eng(seed); std::uniform_int_distribution dist( 'A', @@ -307,6 +307,7 @@ TEST(StringsLowerUpperAscii, Random) { i = dist(eng); } + data.back() = 0; { { auto begin = high_resolution_clock::now(); @@ -332,9 +333,9 @@ TEST(StringsLowerUpperUtf8, Random) std::random_device device; auto seed = device(); std::cout << "seeded with: " << seed << std::endl; - std::vector data(limit); - std::vector res_new(limit, 0); - std::vector res_old(limit, 0); + std::vector data(limit + 1); + std::vector res_new(limit + 1, 0); + std::vector res_old(limit + 1, 0); std::default_random_engine eng(seed); std::uniform_int_distribution dist( std::numeric_limits::min(), @@ -343,6 +344,7 @@ TEST(StringsLowerUpperUtf8, Random) { i = dist(eng); } + data.back() = 0; { { auto begin = high_resolution_clock::now();