Skip to content

Commit a0404b5

Browse files
branch-4.0: [fix](ut) Fix SegmentCorruptionTest ASAN heap-buffer-overflow #58456 (#58498)
Cherry-picked from #58456 Co-authored-by: zzzxl <[email protected]>
1 parent d93826b commit a0404b5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

be/test/olap/rowset/segment_v2/segment_corruption_test.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ class SegmentCorruptionTest : public testing::Test {
8383
// background threads from accessing SyncPoint during/after destruction
8484
SyncPoint::get_instance()->disable_processing();
8585

86-
if (ExecEnv::GetInstance()->file_cache_factory() != nullptr) {
87-
io::FileCacheFactory::instance()->clear_file_caches(true);
86+
auto* factory = io::FileCacheFactory::instance();
87+
if (factory != nullptr) {
88+
factory->clear_file_caches(true);
89+
90+
factory->_caches.clear();
91+
factory->_path_to_cache.clear();
8892
}
8993

9094
// Give background threads time to stop after cache destruction
@@ -132,8 +136,12 @@ class SegmentCorruptionTest : public testing::Test {
132136
// background threads from accessing SyncPoint during/after destruction
133137
SyncPoint::get_instance()->disable_processing();
134138

135-
if (ExecEnv::GetInstance()->file_cache_factory() != nullptr) {
136-
io::FileCacheFactory::instance()->clear_file_caches(true);
139+
auto* factory = io::FileCacheFactory::instance();
140+
if (factory != nullptr) {
141+
factory->clear_file_caches(true);
142+
143+
factory->_caches.clear();
144+
factory->_path_to_cache.clear();
137145
}
138146

139147
// Give background threads time to stop after cache destruction

0 commit comments

Comments
 (0)