This is an automated email from the ASF dual-hosted git repository.

zclllyybb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new efc0a09769f [fix](be) Fix duplicate symbol __lsan_ignore_object when 
build be ut in LSAN (#64164)
efc0a09769f is described below

commit efc0a09769f77eda09a3efaf766e1266c43f8a53
Author: heguanhui <[email protected]>
AuthorDate: Mon Jun 22 16:43:55 2026 +0800

    [fix](be) Fix duplicate symbol __lsan_ignore_object when build be ut in 
LSAN (#64164)
    
    Issue Number: close #64163
    
    error log:
    
    
[master_LSAN.log](https://github.com/user-attachments/files/28677514/master_LSAN.log)
    log after fix:
    
    
[lsan_duplicate_symbol_LSAN.log](https://github.com/user-attachments/files/28677527/lsan_duplicate_symbol_LSAN.log)
    
    
[doris_be_test.xml](https://github.com/user-attachments/files/28677529/doris_be_test.xml)
    
    Related PR: #
    
    Problem Summary: When building BE unit tests in LSAN mode, the linker
    reports a duplicate symbol error for `__lsan_ignore_object`. The root
    cause is that `phdr_cache.cpp` manually declares and defines
    `__lsan_ignore_object`, which conflicts with the LSAN runtime library
    that already provides this symbol. Additionally, `leak_annotations.h`
    only enables `ANNOTATE_LEAKING_OBJECT_PTR` under `address_sanitizer` but
    not under `leak_sanitizer` independently.
    
    The fix:
    1. Replace the manual `__lsan_ignore_object` declaration/definition in
    `phdr_cache.cpp` with the existing `ANNOTATE_LEAKING_OBJECT_PTR` macro
    from `leak_annotations.h`
    2. Extend `leak_annotations.h` to also enable
    `ANNOTATE_LEAKING_OBJECT_PTR` when `leak_sanitizer` is detected (not
    just `address_sanitizer`)
    3. fix LocalFileSystemTest.TestGlob hardcoded path incompatible with
    non-ASAN builds, I found this when testing, and fix it btw
    
    Co-authored-by: root <root@DESKTOP-3AF37B>
---
 be/src/common/phdr_cache.cpp         | 10 ++--------
 be/src/util/debug/leak_annotations.h | 18 +++++++++++++-----
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/be/src/common/phdr_cache.cpp b/be/src/common/phdr_cache.cpp
index e0f5ff43fed..4ab863a462b 100644
--- a/be/src/common/phdr_cache.cpp
+++ b/be/src/common/phdr_cache.cpp
@@ -106,13 +106,7 @@ extern "C"
 }
 */
 
-extern "C" {
-#ifdef ADDRESS_SANITIZER
-void __lsan_ignore_object(const void*);
-#else
-void __lsan_ignore_object(const void*) {} // NOLINT
-#endif
-}
+#include "util/debug/leak_annotations.h"
 
 void updatePHDRCache() {
     // Fill out ELF header cache for access without locking.
@@ -132,7 +126,7 @@ void updatePHDRCache() {
     phdr_cache.store(new_phdr_cache);
 
     /// Memory is intentionally leaked.
-    __lsan_ignore_object(new_phdr_cache);
+    ANNOTATE_LEAKING_OBJECT_PTR(new_phdr_cache);
 }
 
 bool hasPHDRCache() {
diff --git a/be/src/util/debug/leak_annotations.h 
b/be/src/util/debug/leak_annotations.h
index 39351a27735..16a289d85a0 100644
--- a/be/src/util/debug/leak_annotations.h
+++ b/be/src/util/debug/leak_annotations.h
@@ -21,16 +21,24 @@
 // Does nothing if LeakSanitizer is not enabled.
 #define ANNOTATE_LEAKING_OBJECT_PTR(p)
 
+// Check if LeakSanitizer is enabled
 #if defined(__has_feature)
-#if __has_feature(address_sanitizer)
-#if defined(__linux__)
+#if __has_feature(address_sanitizer) || __has_feature(leak_sanitizer)
+#define DORIS_LSAN_ENABLED 1
+#endif
+#endif
+
+#if !defined(DORIS_LSAN_ENABLED) && (defined(ADDRESS_SANITIZER) || 
defined(LEAK_SANITIZER))
+#define DORIS_LSAN_ENABLED 1
+#endif
+
+// DORIS_LSAN_ENABLED && __linux__
+#if defined(DORIS_LSAN_ENABLED) && defined(__linux__)
 
 #undef ANNOTATE_LEAKING_OBJECT_PTR
 #define ANNOTATE_LEAKING_OBJECT_PTR(p) __lsan_ignore_object(p);
 
-#endif
-#endif
-#endif
+#endif // DORIS_LSAN_ENABLED && __linux__
 
 // API definitions from LLVM lsan_interface.h
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to