From c85234e3386158990c0e7b6bc691fad690fa08b9 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Tue, 29 Sep 2026 16:36:45 +0800 Subject: [PATCH] SDSTOR-25766: fix sanitizer check --- conanfile.py | 2 +- src/lib/homestore_backend/CMakeLists.txt | 6 +++++- src/lib/homestore_backend/hs_homeobject.cpp | 23 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index 923e29c5..4df87674 100644 --- a/conanfile.py +++ b/conanfile.py @@ -10,7 +10,7 @@ class HomeObjectConan(ConanFile): name = "homeobject" - version = "5.0.0" + version = "5.0.1" homepage = "https://github.com/eBay/HomeObject" description = "Blob Store built on HomeStore" diff --git a/src/lib/homestore_backend/CMakeLists.txt b/src/lib/homestore_backend/CMakeLists.txt index c426330d..2413b92e 100644 --- a/src/lib/homestore_backend/CMakeLists.txt +++ b/src/lib/homestore_backend/CMakeLists.txt @@ -188,6 +188,9 @@ add_test(NAME HomestoreTestScrubber COMMAND homestore_test_scrubber -csv error - --override_config nuraft_mesg_config.mesg_factory_config.data_request_deadline_secs:10) # All tests share disk, port, and shared-memory resources, so run them serially to avoid parallel conflicts. +# LSAN_OPTIONS=leak_check_at_exit=0: HSHomeObject::shutdown() now runs the leak check itself, right after +# iomanager.stop() returns (all worker threads already joined), to avoid racing LSan's own at-exit scan +# against that same teardown (see hs_homeobject.cpp:shutdown()). This disables the redundant, racy automatic scan. set_tests_properties( HomestoreTestBlob HomestoreTestMisc @@ -200,7 +203,8 @@ set_tests_properties( HomestoreTestGC HomestoreTestGC_ShardRaceTests HomestoreTestScrubber - PROPERTIES RUN_SERIAL TRUE) + PROPERTIES RUN_SERIAL TRUE + ENVIRONMENT "LSAN_OPTIONS=leak_check_at_exit=0") diff --git a/src/lib/homestore_backend/hs_homeobject.cpp b/src/lib/homestore_backend/hs_homeobject.cpp index 84c68b05..a5b3a851 100644 --- a/src/lib/homestore_backend/hs_homeobject.cpp +++ b/src/lib/homestore_backend/hs_homeobject.cpp @@ -11,6 +11,18 @@ #include #include +#if defined(__SANITIZE_ADDRESS__) +#define HO_HAS_LSAN 1 +#elif defined(__has_feature) +#if __has_feature(address_sanitizer) +#define HO_HAS_LSAN 1 +#endif +#endif + +#if defined(HO_HAS_LSAN) +#include +#endif + #include #include "hs_homeobject.hpp" #include "heap_chunk_selector.h" @@ -557,6 +569,17 @@ void HSHomeObject::shutdown() { gc_mgr_.reset(); scrub_mgr_.reset(); iomanager.stop(); + + // Run LSan's leak check here, now that iomanager.stop() has fully joined every worker thread, instead of + // relying on its automatic at-exit scan: that scan runs concurrently with the same thread teardown and can + // lose a race in the sanitizer runtime's own pipe-based memory-accessibility probe (IsAccessibleMemoryRange), + // aborting the process with a "CHECK failed ... write_errno" crash. Doing it here, synchronously after + // iomanager.stop() returns, avoids that race while still catching real leaks. + // LSAN_OPTIONS=leak_check_at_exit=0 (set for these ctest targets) disables the redundant automatic scan. +#if defined(HO_HAS_LSAN) + __lsan_do_leak_check(); +#endif + LOGI("complete shutting down HomeStore"); }