Skip to content

Commit 3c7a9f6

Browse files
committed
[fix](build) Link getentropy compatibility explicitly under ASAN
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: ASAN provides a weak getentropy interceptor that satisfies references from Abseil before the linker scans the glibc compatibility archive. The Doris implementation is not extracted, and on glibc 2.17 the interceptor calls a null real_getentropy pointer during Arrow Flight initialization. Move the existing implementation into glibc-compatibility-explicit while preserving the sys/random.h guard, the ARM ASAN memcpy exclusion, and the vendored source's Clang conversion-warning policy. ### Release note Fix an ASAN crash when initializing Arrow Flight on glibc 2.17 systems. ### Check List (For Author) - Test: Manual before/after reproducer using the actual compatibility CMake targets and Abseil with Clang 20.1.8 on CentOS 7/glibc 2.17. ASAN_UT, ASAN+UBSAN and Debug passed entropy and boundary/error checks; ELF requirements remain at or below GLIBC_2.17. ARM and missing-header CMake branches verified by configuration. RemoteDorisV2ReaderTest.* could not build because the local libarrow_compute.a dependency is missing. - Behavior changed: Yes, the existing getentropy compatibility implementation is always linked when sys/random.h is available. - Does this need documentation: No
1 parent 73be014 commit 3c7a9f6

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎be/src/glibc-compatibility/CMakeLists.txt‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ if (GLIBC_COMPATIBILITY)
4545
endif ()
4646

4747
list(REMOVE_ITEM glibc_compatibility_sources musl/getentropy.c)
48-
if(HAVE_SYS_RANDOM_H)
49-
list(APPEND glibc_compatibility_sources musl/getentropy.c)
50-
endif()
5148

5249
# lance_c is linked after this archive and introduces these libc references
5350
# too late for another archive scan. Keep the hidden version adapters in the
@@ -83,6 +80,16 @@ if (GLIBC_COMPATIBILITY)
8380
${lance_compatibility_source}
8481
)
8582
endif()
83+
if(HAVE_SYS_RANDOM_H)
84+
# ASAN's weak getentropy interceptor prevents extracting our implementation
85+
# from the static archive. Link it explicitly so calls do not reach a null
86+
# real_getentropy on glibc < 2.25.
87+
target_sources(glibc-compatibility-explicit PRIVATE musl/getentropy.c)
88+
if (COMPILER_CLANG)
89+
# Preserve the warning policy previously supplied by the archive target.
90+
set_source_files_properties(musl/getentropy.c PROPERTIES COMPILE_OPTIONS -Wno-conversion)
91+
endif()
92+
endif()
8693
target_compile_options(glibc-compatibility-explicit PRIVATE -fPIC)
8794
add_library(glibc-compatibility STATIC ${glibc_compatibility_sources})
8895
target_compile_options(

0 commit comments

Comments
 (0)