Version
trunk
What's Wrong?
On aarch64, building Doris BE with LSAN, ASAN, ASAN_UT, or UBSAN sanitizer modes fails.
1. LSAN/ASAN/ASAN_UT - CMake configuration failure
The OpenBLAS getarch build-time tool inherits sanitizer flags from the parent CMake context, which causes LeakSanitizer to detect memory leaks in OpenBLAS's detect() function (strdup without free on aarch64). This causes getarch to exit with non-zero code, and CMake configuration fails.
Error example (LSAN):
==641==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 480 byte(s) in 96 object(s) allocated from:
#0 malloc
#1 strdup
#2 detect (getarch)
#3 get_corename (getarch)
#4 main (getarch)
SUMMARY: LeakSanitizer: 972 byte(s) leaked in 194 allocation(s).
Additionally, __lsan_ignore_object is only enabled under ADDRESS_SANITIZER but LEAK_SANITIZER also provides this symbol. Under LSAN mode, an empty stub is used instead, causing link errors:
undefined reference to '__lsan_ignore_object'
2. UBSAN - Compilation failure
-mcmodel=medium is x86_64-specific and unsupported on aarch64. It is hardcoded in CXX_FLAGS_UBSAN and causes compilation failure:
clang: error: unsupported argument 'medium' to option '-mcmodel=' for target 'aarch64-unknown-linux-gnu'
After fixing -mcmodel=medium, UBSAN build on aarch64 also fails due to -Wunused-macros errors (promoted to errors by -Werror):
2a. -Wno-unused-macros suppression not working for flex/bison generated files — the flag was incorrectly gated behind the -Wno-unused-but-set-variable check in be/src/exprs/CMakeLists.txt, so the suppression never took effect:
be/ut_build_UBSAN/__/gensrc/build/geo/wkt_lex.l.cpp:7:9: error: macro is not used [-Werror,-Wunused-macros]
7 | #define FLEX_SCANNER
| ^~~~~~~~~~~~~
be/ut_build_UBSAN/__/gensrc/build/geo/wkt_yacc.y.cpp:80:9: error: macro is not used [-Werror,-Wunused-macros]
80 | #define YYCOPY(Dst, Src, Count) \
| ^
2b. Unused #define PMR macro in function_string_misc.cpp:
be/src/exprs/function/function_string_misc.cpp:82:9: error: macro is not used [-Werror,-Wunused-macros]
82 | #define PMR std::pmr
| ^~~
2c. Unused ALIGN_CACHE_LINE and PURE macros in compiler_util.h:
be/src/common/compiler_util.h:51:9: error: macro is not used [-Werror,-Wunused-macros]
51 | #define ALIGN_CACHE_LINE __attribute__((aligned(CACHE_LINE_SIZE)))
| ^~~~~~~~~~~~~~~~
be/src/common/compiler_util.h:53:9: error: macro is not used [-Werror,-Wunused-macros]
53 | #define PURE __attribute__((pure))
| ^~~~
3. TSAN - CMake configuration failure
The OpenBLAS getarch build-time tool inherits -fsanitize=thread flag, causing getarch to produce incorrect output. This leads to SGEMM_DEFAULT_UNROLL_M and other macros being undefined when compiling getarch_2nd, resulting in CMake configuration failure.
Error example:
error: use of undeclared identifier 'SGEMM_DEFAULT_UNROLL_M'
22 | printf("SGEMM_UNROLL_M=%d\n", SGEMM_DEFAULT_UNROLL_M);
Note: TSAN was verified to work on aarch64 without additional changes after the sanitizer flag stripping fix.
What You Expected?
BE should build successfully with LSAN/ASAN/ASAN_UT/UBSAN/TSAN sanitizer modes on aarch64, and BE UT should run normally.
How to Reproduce?
On an aarch64 machine:
- Build Doris BE with LSAN mode:
BUILD_TYPE=LSAN bash build.sh --be
- Or with ASAN_UT mode:
BUILD_TYPE=ASAN_UT bash build.sh --be
- Or with ASAN mode:
BUILD_TYPE=ASAN bash build.sh --be
- Or with UBSAN mode:
BUILD_TYPE=UBSAN bash build.sh --be
- Or with TSAN mode:
BUILD_TYPE=TSAN bash build.sh --be
- CMake configuration or compilation fails
Are you willing to submit PR?
Yes
Version
trunk
What's Wrong?
On aarch64, building Doris BE with LSAN, ASAN, ASAN_UT, or UBSAN sanitizer modes fails.
1. LSAN/ASAN/ASAN_UT - CMake configuration failure
The OpenBLAS getarch build-time tool inherits sanitizer flags from the parent CMake context, which causes LeakSanitizer to detect memory leaks in OpenBLAS's
detect()function (strdup without free on aarch64). This causes getarch to exit with non-zero code, and CMake configuration fails.Error example (LSAN):
Additionally,
__lsan_ignore_objectis only enabled underADDRESS_SANITIZERbutLEAK_SANITIZERalso provides this symbol. Under LSAN mode, an empty stub is used instead, causing link errors:2. UBSAN - Compilation failure
-mcmodel=mediumis x86_64-specific and unsupported on aarch64. It is hardcoded inCXX_FLAGS_UBSANand causes compilation failure:After fixing
-mcmodel=medium, UBSAN build on aarch64 also fails due to-Wunused-macroserrors (promoted to errors by-Werror):2a.
-Wno-unused-macrossuppression not working for flex/bison generated files — the flag was incorrectly gated behind the-Wno-unused-but-set-variablecheck inbe/src/exprs/CMakeLists.txt, so the suppression never took effect:2b. Unused
#define PMRmacro infunction_string_misc.cpp:2c. Unused
ALIGN_CACHE_LINEandPUREmacros incompiler_util.h:3. TSAN - CMake configuration failure
The OpenBLAS getarch build-time tool inherits
-fsanitize=threadflag, causing getarch to produce incorrect output. This leads toSGEMM_DEFAULT_UNROLL_Mand other macros being undefined when compiling getarch_2nd, resulting in CMake configuration failure.Error example:
Note: TSAN was verified to work on aarch64 without additional changes after the sanitizer flag stripping fix.
What You Expected?
BE should build successfully with LSAN/ASAN/ASAN_UT/UBSAN/TSAN sanitizer modes on aarch64, and BE UT should run normally.
How to Reproduce?
On an aarch64 machine:
BUILD_TYPE=LSAN bash build.sh --beBUILD_TYPE=ASAN_UT bash build.sh --beBUILD_TYPE=ASAN bash build.sh --beBUILD_TYPE=UBSAN bash build.sh --beBUILD_TYPE=TSAN bash build.sh --beAre you willing to submit PR?
Yes