Skip to content

[fix](build) Fix ASAN getentropy crash on glibc 2.17 - #67848

Merged
morningman merged 1 commit into
apache:masterfrom
hubgeter:fix/asan-getentropy-compat
Sep 11, 2026
Merged

[fix](build) Fix ASAN getentropy crash on glibc 2.17#67848
morningman merged 1 commit into
apache:masterfrom
hubgeter:fix/asan-getentropy-compat

Conversation

@hubgeter

@hubgeter hubgeter commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

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 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
    • 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.
    • Yes.
  • Does this need documentation?
    • 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: 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
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hubgeter

Copy link
Copy Markdown
Contributor Author

run buildall

@hubgeter

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.c implementation from an extract-on-demand static archive into the directly linked glibc-compatibility-explicit object 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_H guard, ARM ASAN/ASAN_UT memcpy exclusion, PIC/include handling, and the Clang -Wno-conversion policy 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_LIBS executable consumer were traced. No missed path or second BE strong getentropy definition 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.c is already in the same explicit target. Production doris_be retains 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 because libarrow_compute.a was missing. At submission time, exact-head COMPILE and BE UT CI 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.

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.33% (34625/45362)
Line Coverage 61.26% (389078/635166)
Region Coverage 57.48% (326430/567930)
Branch Coverage 58.30% (148871/255343)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16872 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 3c7a9f69b833e8a84a0a434d23ce48cd52008077, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17745	3071	3064	3064
q2	2075	256	224	224
q3	10263	886	525	525
q4	4667	253	212	212
q5	7663	558	390	390
q6	140	114	95	95
q7	530	581	404	404
q8	9238	876	907	876
q9	3532	2433	2403	2403
q10	6536	858	712	712
q11	393	197	179	179
q12	609	263	204	204
q13	18119	1525	1155	1155
q14	164	150	143	143
q15	q16	442	405	373	373
q17	1372	913	747	747
q18	3108	2304	2288	2288
q19	1270	928	795	795
q20	369	285	199	199
q21	5591	1649	1928	1649
q22	325	276	235	235
Total cold run time: 94151 ms
Total hot run time: 16872 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3441	3365	3374	3365
q2	512	404	389	389
q3	2313	2433	2238	2238
q4	1207	1180	921	921
q5	2216	2142	2129	2129
q6	170	122	90	90
q7	1065	928	878	878
q8	1596	1389	1406	1389
q9	3203	3157	3149	3149
q10	1899	1813	1666	1666
q11	362	269	255	255
q12	461	439	350	350
q13	1504	1528	1163	1163
q14	180	185	172	172
q15	q16	403	396	366	366
q17	3663	3447	3371	3371
q18	4916	4554	4978	4554
q19	959	858	864	858
q20	1015	989	830	830
q21	3918	3248	3240	3240
q22	385	342	321	321
Total cold run time: 35388 ms
Total hot run time: 31694 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 83187 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 3c7a9f69b833e8a84a0a434d23ce48cd52008077, data reload: false

query5	4247	426	330	330
query6	377	136	130	130
query7	4950	441	234	234
query8	291	133	133	133
query9	8708	2907	2917	2907
query10	392	212	187	187
query11	5384	1049	916	916
query12	136	71	71	71
query13	1186	464	302	302
query14	6163	2230	2100	2100
query14_1	2015	2007	1992	1992
query15	171	122	116	116
query16	919	391	362	362
query17	801	455	383	383
query18	2318	314	232	232
query19	158	136	105	105
query20	76	70	77	70
query21	202	105	85	85
query22	5496	5578	5501	5501
query23	6951	6441	6163	6163
query23_1	6175	6205	6338	6205
query24	7264	1090	757	757
query24_1	744	765	753	753
query25	413	285	235	235
query26	1217	239	134	134
query27	2805	410	250	250
query28	4700	1492	1489	1489
query29	918	429	339	339
query30	248	159	131	131
query31	822	409	335	335
query32	135	80	76	76
query33	463	213	182	182
query34	980	844	486	486
query35	405	399	346	346
query36	593	537	505	505
query37	122	80	69	69
query38	1007	859	824	824
query39	506	487	478	478
query39_1	474	456	477	456
query40	213	95	75	75
query41	58	55	50	50
query42	73	71	75	71
query43	244	243	209	209
query44	979	540	549	540
query45	109	108	105	105
query46	771	835	515	515
query47	769	779	717	717
query48	312	298	241	241
query49	557	245	216	216
query50	720	272	195	195
query51	8309	8265	8072	8072
query52	73	75	64	64
query53	202	206	156	156
query54	236	288	157	157
query55	79	62	60	60
query56	201	181	187	181
query57	686	653	656	653
query58	204	168	168	168
query59	1236	1271	1125	1125
query60	222	184	174	174
query61	116	138	114	114
query62	338	210	178	178
query63	178	144	141	141
query64	2667	743	589	589
query65	1643	1657	1651	1651
query66	1776	253	201	201
query67	9895	10018	10264	10018
query68	2944	1211	740	740
query69	345	231	207	207
query70	686	622	613	613
query71	246	182	165	165
query72	2300	1720	1518	1518
query73	652	566	335	335
query74	1977	1284	1147	1147
query75	1196	1125	977	977
query76	2367	710	517	517
query77	246	270	201	201
query78	4054	3818	3365	3365
query79	2770	848	572	572
query80	1634	342	282	282
query81	508	159	141	141
query82	950	125	96	96
query83	290	213	195	195
query84	295	110	87	87
query85	808	347	293	293
query86	470	179	166	166
query87	1036	991	903	903
query88	3010	2141	2124	2124
query89	297	198	179	179
query90	2073	136	130	130
query91	130	120	98	98
query92	92	71	72	71
query93	1988	1179	665	665
query94	638	257	216	216
query95	538	325	228	228
query96	863	597	266	266
query97	1079	1099	1042	1042
query98	173	136	132	132
query99	429	342	313	313
Total cold run time: 180312 ms
Total hot run time: 83187 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.89 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 3c7a9f69b833e8a84a0a434d23ce48cd52008077, data reload: false

query1	0.00	0.00	0.01
query2	0.08	0.04	0.04
query3	0.25	0.11	0.11
query4	1.60	0.10	0.10
query5	0.18	0.16	0.16
query6	1.24	0.68	0.70
query7	0.04	0.01	0.00
query8	0.05	0.03	0.03
query9	0.29	0.22	0.22
query10	0.36	0.34	0.33
query11	0.16	0.11	0.12
query12	0.15	0.13	0.12
query13	0.30	0.32	0.31
query14	0.46	0.46	0.47
query15	0.36	0.34	0.36
query16	0.20	0.24	0.24
query17	0.69	0.65	0.68
query18	0.17	0.16	0.17
query19	1.19	1.16	1.21
query20	0.02	0.01	0.01
query21	15.52	0.15	0.12
query22	5.07	0.04	0.04
query23	16.18	0.25	0.10
query24	2.98	0.31	0.25
query25	0.12	0.05	0.03
query26	0.74	0.17	0.13
query27	0.04	0.03	0.04
query28	3.60	0.54	0.29
query29	12.47	3.22	2.58
query30	0.25	0.11	0.11
query31	2.76	0.36	0.17
query32	3.52	0.32	0.24
query33	1.39	1.42	1.48
query34	15.35	2.31	1.86
query35	1.83	1.78	1.78
query36	0.45	0.30	0.28
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.08	0.08
query41	0.08	0.03	0.02
query42	0.03	0.02	0.02
query43	0.03	0.02	0.02
Total cold run time: 90.44 s
Total hot run time: 14.89 s

@morningman
morningman merged commit 859a19c into apache:master Sep 11, 2026
44 checks passed
yiguolei pushed a commit that referenced this pull request Sep 11, 2026
### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants