heguanhui opened a new issue, #64163:
URL: https://github.com/apache/doris/issues/64163

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   master
   
   ### What's Wrong?
   
   When building BE unit tests in LSAN+UBSAN mode, the linker reports a 
duplicate symbol error:
   
   ```
   ld.lld: error: duplicate symbol: __lsan_ignore_object
   >>> defined at lsan_common.cpp.o:(__lsan_ignore_object) in archive 
/var/local/ldb-toolchain/tmp/gentoo/llvm/bin/../../../../lib/clang/20/lib/linux/libclang_rt.lsan-x86_64.a
   >>> defined at phdr_cache.cpp:113 
(./be/ut_build_LSAN/./be/src/common/phdr_cache.cpp:113)
   >>>            phdr_cache.cpp.o:(.text+0x0) in archive src/common/libCommon.a
   clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)
   ```
   
   ### What You Expected?
   
   BE UT should build and run successfully in LSAN+UBSAN mode without duplicate 
symbol errors.
   
   ### How to Reproduce?
   
   1. Build BE with LSAN+UBSAN mode
   2. Run `bash run-be-ut.sh`
   3. Linker fails with duplicate symbol `__lsan_ignore_object`
   
   ### Root Cause
   
   In `be/src/common/phdr_cache.cpp`, the `__lsan_ignore_object` function is 
manually declared and defined:
   
   ```cpp
   extern "C" {
   #ifdef ADDRESS_SANITIZER
   void __lsan_ignore_object(const void*);
   #else
   void __lsan_ignore_object(const void*) {} // NOLINT
   #endif
   }
   ```
   
   When building with LSAN (Leak Sanitizer) enabled, the LSAN runtime library 
(`libclang_rt.lsan-x86_64.a`) already provides the `__lsan_ignore_object` 
symbol. The manual definition in `phdr_cache.cpp` conflicts with it, causing 
the duplicate symbol error.
   
   Additionally, `be/src/util/debug/leak_annotations.h` only enables 
`ANNOTATE_LEAKING_OBJECT_PTR` when `address_sanitizer` is detected, but not 
when `leak_sanitizer` is detected independently. This means the existing 
annotation mechanism does not work properly under LSAN-only mode.
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to