[fix](build) Fix ASAN getentropy crash on glibc 2.17 - #67848
Conversation
### 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
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
|
/review |
There was a problem hiding this comment.
Review opinion: approve; no blocking findings.
Reviewed exact head 3c7a9f69b833e8a84a0a434d23ce48cd52008077 against base 1b91bfa4356cca84de710c354b45fa265e5671a6.
Critical checkpoint conclusions:
- Goal and proof: The change addresses the reported CentOS 7 ASAN crash by moving the existing
musl/getentropy.cimplementation from an extract-on-demand static archive into the directly linkedglibc-compatibility-explicitobject target. CMake 3.19 includes a directly linked object library's objects in each consuming final link, and the resulting strong C definition overrides compiler-rt's weak public interceptor without relying on archive extraction. The existing Arrow Flight initialization path is the end-to-end trigger. - Scope and clarity: The PR is narrowly limited to the necessary CMake target relocation. It preserves the existing source implementation,
HAVE_SYS_RANDOM_Hguard, ARM ASAN/ASAN_UTmemcpyexclusion, PIC/include handling, and the Clang-Wno-conversionpolicy required by this source. - Parallel and conditional paths: The header-present/header-missing branches, x86_64/aarch64 target construction, Clang/GCC warning behavior, all supported build types, and every direct
DORIS_LINK_LIBS/TEST_LINK_LIBSexecutable consumer were traced. No missed path or second BE stronggetentropydefinition was found; macOS disables glibc compatibility and is unaffected. - Compatibility and runtime semantics: The unchanged implementation retains the 256-byte/EIO contract, EINTR and short-read loop, cancellation disable/restore behavior, and underlying error propagation.
musl/getrandom.cis already in the same explicit target. Productiondoris_beretains the mandatory post-link audit that rejects undefined GLIBC requirements newer than 2.17. No FE/BE protocol, storage format, rolling-upgrade, configuration, or persistence compatibility is involved. - Concurrency, lifecycle, memory, and error handling: No shared state, new thread entry, lock, allocation ownership, static-initialization dependency, or new error-handling path is introduced. The existing non-cancellation and error-return behavior is unchanged.
- Performance and observability: The change adds one small regular object to affected final links and does not add runtime work beyond calls that already selected this implementation. It creates no new operational state requiring logs, metrics, or configuration observability.
- Transactions and data correctness: No transaction, persistence, visibility, delete-bitmap, data-write, nullable-column, or FE/BE variable-passing path is touched.
- Tests and results: No test result file is changed. The commit reports a CentOS 7/glibc 2.17 before/after reproducer with Clang 20.1.8 across ASAN_UT, ASAN+UBSAN, and Debug, including entropy, boundary/error, configuration-branch, and ELF-version checks.
RemoteDorisV2ReaderTest.*was not built in that manual environment becauselibarrow_compute.awas missing. At submission time, exact-headCOMPILEandBE UTCI are still pending, so this review does not claim those checks have passed; the review runner was also instructed not to build. - User focus: No additional user-provided focus was supplied; the complete PR was reviewed.
The main-agent scan plus one full-scope and two risk-focused reviews converged in Round 1. All reviewers returned NO_NEW_VALUABLE_FINDINGS, all three initial risk hypotheses were independently resolved with code/toolchain evidence, and the final changed-file and unresolved-candidate sweep found no issue requiring an inline comment.
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 16872 ms |
TPC-DS: Total hot run time: 83187 ms |
ClickBench: Total hot run time: 14.89 s |
### What problem does this PR solve? Related PR: #67848, #67752 Problem Summary: Backport #67848 to `branch-4.1`. The compatibility source and CMake change are identical to the master fix. BE unit tests can crash at address zero while Arrow Flight initializes Abseil random seeds on CentOS 7 (glibc 2.17). ASAN's weak `getentropy` interceptor satisfies the reference before the linker scans `libglibc-compatibility.a`, so Doris' compatibility implementation is not extracted. Since glibc 2.17 has no `getentropy`, the interceptor calls a null `real_getentropy` pointer. Restoring the CentOS 7 CI image exposed this existing gap. Link the existing `musl/getentropy.c` through `glibc-compatibility-explicit`, just like `getrandom`. Preserve the existing `HAVE_SYS_RANDOM_H` guard, ARM ASAN `memcpy` exclusion, and this source file's Clang conversion-warning policy. The C implementation and Flight cancellation logic are unchanged. ### Release note None ### Check List (For Author) - Test - [ ] Regression test - [ ] Unit Test - [x] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason - Behavior changed: - [ ] No. - [x] Yes. - Does this need documentation? - [x] No. - [ ] Yes. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label
What problem does this PR solve?
Issue Number: N/A
Related PR: #67752
Problem Summary:
BE unit tests can crash at address zero while Arrow Flight initializes Abseil random seeds on CentOS 7 (glibc 2.17). ASAN's weak
getentropyinterceptor satisfies the reference before the linker scanslibglibc-compatibility.a, so Doris' compatibility implementation is not extracted. Since glibc 2.17 has nogetentropy, the interceptor calls a nullreal_getentropypointer. Restoring the CentOS 7 CI image exposed this existing gap.Link the existing
musl/getentropy.cthroughglibc-compatibility-explicit, just likegetrandom. Preserve the existingHAVE_SYS_RANDOM_Hguard, ARM ASANmemcpyexclusion, and this source file's Clang conversion-warning policy. The C implementation and Flight cancellation logic are unchanged.Release note
None
Check List (For Author)
Check List (For Reviewer who merge this PR)