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 04624351573 [fix](be ut) Skip custom memcpy on ARM+ASAN to fix 
segfault at process startup (#63656)
04624351573 is described below

commit 04624351573ea14ae15e3ce06ba7b4e206643918
Author: heguanhui <[email protected]>
AuthorDate: Mon Jun 1 14:43:46 2026 +0800

    [fix](be ut) Skip custom memcpy on ARM+ASAN to fix segfault at process 
startup (#63656)
    
    The glibc-compatibility module provides a custom memcpy implementation
    (memcpy_aarch64.cpp) that overrides the global memcpy symbol via extern
    "C". This is done to avoid dependency on a specific glibc symbol version
    (e.g., memcpy@@GLIBC_2.14) for portability.
    
    However, libpthread's __pthread_initialize_minimal() calls memcpy during
    very early process startup — before main(), before C++ static
    initialization, and before ASAN shadow memory is set up. When ASAN is
    enabled, the custom memcpy accesses memory that ASAN shadow has not yet
    mapped, resulting in SIGSEGV.
    
    This only affects aarch64 + ASAN because:
    
    RELEASE builds have no ASAN shadow memory checks
    x86_64 + ASAN does not exhibit this crash (different shadow memory
    layout and initialization timing)
    
    Co-authored-by: root <root@DESKTOP-3AF37B>
---
 be/src/glibc-compatibility/CMakeLists.txt | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/be/src/glibc-compatibility/CMakeLists.txt 
b/be/src/glibc-compatibility/CMakeLists.txt
index 99c428ba132..370d7346691 100644
--- a/be/src/glibc-compatibility/CMakeLists.txt
+++ b/be/src/glibc-compatibility/CMakeLists.txt
@@ -59,7 +59,16 @@ if (GLIBC_COMPATIBILITY)
     list(REMOVE_ITEM glibc_compatibility_sources musl/getrandom.c)
     # NOTE(amos): sanitizers might generate memcpy references that are too 
late to
     # refer. Let's also extract memcpy definitions explicitly to avoid UNDEF 
GLIBC 2.14.
-    add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c 
${MEMCPY_SOURCE})
+    #
+    # NOTE: On ARM (aarch64) with ASAN, the custom memcpy (memcpy_aarch64.cpp) 
overrides
+    # the global memcpy symbol. libpthread's __pthread_initialize_minimal() 
calls memcpy
+    # before ASAN shadow memory is initialized, causing SIGSEGV. Skip custom 
memcpy in
+    # this case and fall back to glibc's memcpy.
+    if (ARCH_ARM AND (CMAKE_BUILD_TYPE STREQUAL "ASAN_UT" OR CMAKE_BUILD_TYPE 
STREQUAL "ASAN"))
+        add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c)
+    else()
+        add_library(glibc-compatibility-explicit OBJECT musl/getrandom.c 
${MEMCPY_SOURCE})
+    endif()
     target_compile_options(glibc-compatibility-explicit PRIVATE -fPIC)
     add_library(glibc-compatibility STATIC ${glibc_compatibility_sources})
     target_compile_options(


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

Reply via email to