mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
fix: memory leak in unittest and open the USE_ASAN option when build unittest (#35855)
issue: #35854 --------- Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
parent
6fd33285e1
commit
b2eb9fe2a7
@ -117,7 +117,7 @@ endif()
|
|||||||
if (LINUX)
|
if (LINUX)
|
||||||
message( STATUS "Building Milvus Unit Test on Linux")
|
message( STATUS "Building Milvus Unit Test on Linux")
|
||||||
option(USE_ASAN "Whether to use AddressSanitizer" OFF)
|
option(USE_ASAN "Whether to use AddressSanitizer" OFF)
|
||||||
if ( USE_ASAN AND false )
|
if ( USE_ASAN )
|
||||||
message( STATUS "Building Milvus using AddressSanitizer")
|
message( STATUS "Building Milvus using AddressSanitizer")
|
||||||
add_compile_options(-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -fsanitize=address)
|
add_compile_options(-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -fsanitize=address)
|
||||||
add_link_options(-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -fsanitize=address)
|
add_link_options(-fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -fsanitize=address)
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
#include "segcore/reduce_c.h"
|
#include "segcore/reduce_c.h"
|
||||||
#include "segcore/segment_c.h"
|
#include "segcore/segment_c.h"
|
||||||
#include "futures/Future.h"
|
#include "futures/Future.h"
|
||||||
|
#include "futures/future_c.h"
|
||||||
#include "test_utils/DataGen.h"
|
#include "test_utils/DataGen.h"
|
||||||
#include "test_utils/PbHelper.h"
|
#include "test_utils/PbHelper.h"
|
||||||
#include "test_utils/indexbuilder_test_utils.h"
|
#include "test_utils/indexbuilder_test_utils.h"
|
||||||
@ -79,6 +80,8 @@ CRetrieve(CSegmentInterface c_segment,
|
|||||||
mu.lock();
|
mu.lock();
|
||||||
|
|
||||||
auto [retrieveResult, status] = futurePtr->leakyGet();
|
auto [retrieveResult, status] = futurePtr->leakyGet();
|
||||||
|
future_destroy(future);
|
||||||
|
|
||||||
if (status.error_code != 0) {
|
if (status.error_code != 0) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -104,6 +107,8 @@ CRetrieveByOffsets(CSegmentInterface c_segment,
|
|||||||
mu.lock();
|
mu.lock();
|
||||||
|
|
||||||
auto [retrieveResult, status] = futurePtr->leakyGet();
|
auto [retrieveResult, status] = futurePtr->leakyGet();
|
||||||
|
future_destroy(future);
|
||||||
|
|
||||||
if (status.error_code != 0) {
|
if (status.error_code != 0) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -433,8 +433,8 @@ TEST(storage, InsertDataFloatNullable) {
|
|||||||
FixedVector<float> data = {1, 2, 3, 4, 5};
|
FixedVector<float> data = {1, 2, 3, 4, 5};
|
||||||
auto field_data =
|
auto field_data =
|
||||||
milvus::storage::CreateFieldData(storage::DataType::FLOAT, true);
|
milvus::storage::CreateFieldData(storage::DataType::FLOAT, true);
|
||||||
uint8_t* valid_data = new uint8_t[1]{0x13};
|
std::array<uint8_t, 1> valid_data = {0x13};
|
||||||
field_data->FillFieldData(data.data(), valid_data, data.size());
|
field_data->FillFieldData(data.data(), valid_data.data(), data.size());
|
||||||
|
|
||||||
storage::InsertData insert_data(field_data);
|
storage::InsertData insert_data(field_data);
|
||||||
storage::FieldDataMeta field_data_meta{100, 101, 102, 103};
|
storage::FieldDataMeta field_data_meta{100, 101, 102, 103};
|
||||||
@ -457,7 +457,7 @@ TEST(storage, InsertDataFloatNullable) {
|
|||||||
data = {1, 2, 0, 0, 5};
|
data = {1, 2, 0, 0, 5};
|
||||||
ASSERT_EQ(data, new_data);
|
ASSERT_EQ(data, new_data);
|
||||||
ASSERT_EQ(new_payload->get_null_count(), 2);
|
ASSERT_EQ(new_payload->get_null_count(), 2);
|
||||||
ASSERT_EQ(*new_payload->ValidData(), *valid_data);
|
ASSERT_EQ(*new_payload->ValidData(), valid_data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(storage, InsertDataDouble) {
|
TEST(storage, InsertDataDouble) {
|
||||||
|
|||||||
@ -2015,12 +2015,12 @@ TEST(Sealed, SkipIndexSkipUnaryRangeNullable) {
|
|||||||
|
|
||||||
//test for int64
|
//test for int64
|
||||||
std::vector<int64_t> int64s = {1, 2, 3, 4, 5};
|
std::vector<int64_t> int64s = {1, 2, 3, 4, 5};
|
||||||
uint8_t* valid_data = new uint8_t[1]{0x03};
|
std::array<uint8_t, 1> valid_data = {0x03};
|
||||||
FixedVector<bool> valid_data_ = {true, true, false, false, false};
|
FixedVector<bool> valid_data_ = {true, true, false, false, false};
|
||||||
auto int64s_field_data =
|
auto int64s_field_data =
|
||||||
storage::CreateFieldData(DataType::INT64, true, 1, 5);
|
storage::CreateFieldData(DataType::INT64, true, 1, 5);
|
||||||
|
|
||||||
int64s_field_data->FillFieldData(int64s.data(), valid_data, 5);
|
int64s_field_data->FillFieldData(int64s.data(), valid_data.data(), 5);
|
||||||
segment->LoadPrimitiveSkipIndex(i64_fid,
|
segment->LoadPrimitiveSkipIndex(i64_fid,
|
||||||
0,
|
0,
|
||||||
DataType::INT64,
|
DataType::INT64,
|
||||||
@ -2084,12 +2084,12 @@ TEST(Sealed, SkipIndexSkipBinaryRangeNullable) {
|
|||||||
|
|
||||||
//test for int64
|
//test for int64
|
||||||
std::vector<int64_t> int64s = {1, 2, 3, 4, 5};
|
std::vector<int64_t> int64s = {1, 2, 3, 4, 5};
|
||||||
uint8_t* valid_data = new uint8_t[1]{0x03};
|
std::array<uint8_t, 1> valid_data = {0x03};
|
||||||
FixedVector<bool> valid_data_ = {true, true, false, false, false};
|
FixedVector<bool> valid_data_ = {true, true, false, false, false};
|
||||||
auto int64s_field_data =
|
auto int64s_field_data =
|
||||||
storage::CreateFieldData(DataType::INT64, true, 1, 5);
|
storage::CreateFieldData(DataType::INT64, true, 1, 5);
|
||||||
|
|
||||||
int64s_field_data->FillFieldData(int64s.data(), valid_data, 5);
|
int64s_field_data->FillFieldData(int64s.data(), valid_data.data(), 5);
|
||||||
segment->LoadPrimitiveSkipIndex(i64_fid,
|
segment->LoadPrimitiveSkipIndex(i64_fid,
|
||||||
0,
|
0,
|
||||||
DataType::INT64,
|
DataType::INT64,
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
#include "segcore/reduce_c.h"
|
#include "segcore/reduce_c.h"
|
||||||
#include "segcore/segment_c.h"
|
#include "segcore/segment_c.h"
|
||||||
#include "futures/Future.h"
|
#include "futures/Future.h"
|
||||||
|
#include "futures/future_c.h"
|
||||||
#include "DataGen.h"
|
#include "DataGen.h"
|
||||||
#include "PbHelper.h"
|
#include "PbHelper.h"
|
||||||
#include "c_api_test_utils.h"
|
#include "c_api_test_utils.h"
|
||||||
@ -193,6 +194,8 @@ CSearch(CSegmentInterface c_segment,
|
|||||||
mu.lock();
|
mu.lock();
|
||||||
|
|
||||||
auto [searchResult, status] = futurePtr->leakyGet();
|
auto [searchResult, status] = futurePtr->leakyGet();
|
||||||
|
future_destroy(future);
|
||||||
|
|
||||||
if (status.error_code != 0) {
|
if (status.error_code != 0) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user