Skip to content

Do not bundle a copy of OpenSSL into the delta-kernel Rust archive - #123889

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-delta-kernel-openssl-bundle
Oct 4, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-delta-kernel-openssl-bundle

Conversation

@groeneai

@groeneai groeneai commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123738

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The delta-kernel-rs library no longer carries its own copy of OpenSSL, so the binary always links the OpenSSL built from contrib/openssl with the current build flags, instead of an older copy kept by the Rust build cache.

Description

Since #123738, 18 of 19 fuzzers abort at startup on master with The size of coverage PC tables does not match the number of instrumented PCs (WeeklyFuzzersCorpus report). Only lexer_fuzzer, which does not link OpenSSL, passes.

Root cause: with OPENSSL_LIBS=ssl:crypto, openssl-sys makes rustc bundle the CMake-built libssl.a/libcrypto.a into libdelta_kernel_ffi.a. That archive comes first on the link line, so the binary takes OpenSSL from it. Neither cargo nor sccache re-keys the archive when only the bundled native objects change, so it keeps old OpenSSL objects: here, objects compiled before #123738 that still have a PC table. The fuzzers' only PC table is therefore OpenSSL's (85087 entries in names_and_types_fuzzer, against 1.8M inline counters). The same staleness shows in the master release build of the OpenSSL 3.5.8 bump (07c5bfb5): its OpenSSL_version_num returns 3.5.7.

Change: OPENSSL_LIBS is empty, so nothing is bundled and the Rust objects resolve OpenSSL from OpenSSL::SSL/OpenSSL::Crypto, which delta_kernel_ffi already links.

Validation with the CI amd_fuzzers configuration: a stale archive reproduces CI's exact counts (names_and_types_fuzzer 1828871 counters / 85087 PCs, compressed_buffer_fuzzer 7325301 / 85432) and the abort. With the change the archive has no OpenSSL objects, the fuzzers have no PC table, and -runs=0, -merge=1 and 60 s of fuzzing pass. The debug binary links one OpenSSL (3.5.8), and the delta-lake stateless tests pass.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/123889]

Version info

  • Merged into: 26.10.1.1544-master (included in 26.10 and later)

With `OPENSSL_LIBS=ssl:crypto` and `OPENSSL_STATIC=1`, the `openssl-sys`
build script emits `cargo:rustc-link-lib=static=ssl` and `static=crypto`,
so rustc bundles the CMake-built `libssl.a` and `libcrypto.a` into the
`openssl-sys` rlib and from there into `libdelta_kernel_ffi.a`. That
archive precedes `libssl.a`/`libcrypto.a` on every link, so the binary
takes OpenSSL from it.

Neither cargo nor sccache re-keys the archive when only the bundled native
objects change (cargo tracks env vars and the include dir for openssl-sys),
so it can keep OpenSSL objects from an older build. After ClickHouse#123738 dropped
the SanitizerCoverage PC table from the fuzzer build, the archive still
held OpenSSL objects compiled with it: every fuzzer that links `dbms` got a
PC table covering OpenSSL only (85087 entries vs 1.8M-11.8M inline
counters), and libFuzzer aborted at startup with "The size of coverage PC
tables does not match the number of instrumented PCs" (18 of 19 fuzzers in
WeeklyFuzzersCorpus on 22e115e). The same mechanism made the master
release build of the OpenSSL 3.5.8 bump (07c5bfb) link 3.5.7 code.

With an empty `OPENSSL_LIBS`, openssl-sys emits no link directive, nothing
is bundled, and the Rust objects' OpenSSL references resolve from
`OpenSSL::SSL`/`OpenSSL::Crypto`, which `delta_kernel_ffi` already links as
INTERFACE libraries. Removing the directive changes openssl-sys's metadata,
so the dependent crates and the staticlib are rebuilt on the first build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 4, 2026
@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 major, 1 nit).

# Sev Finding Verdict Evidence / action
1 ⚠️ CI builds with sccache from an empty target dir, so the fix only takes effect if dropping the -l static=ssl/crypto arguments invalidates the cached libdelta_kernel_ffi.a DISAGREE sccache 0.17.0 probe with the same topology (rlib with -l static, dependent rlib, staticlib reaching it only via -L dependency=): removing -l misses all three and the staticlib has no native object. The PR's Build (amd_fuzzers) artifact will be checked with -runs=0
2 💡 add_dependencies(_cargo-build_delta_kernel_ffi OpenSSL::Crypto OpenSSL::SSL) is no longer needed for bundling DISAGREE harmless ordering constraint; left as is to keep the diff minimal

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261004-190022

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. In the CI amd_fuzzers configuration, building libdelta_kernel_ffi.a with the pre-#123738 flags and then the fuzzers with the current ones leaves the stale OpenSSL in the archive every time; names_and_types_fuzzer -runs=0 aborts with CI's exact 1828871 counters / 85087 PCs.
b Root cause explained? OPENSSL_LIBS=ssl:crypto makes openssl-sys bundle libssl.a/libcrypto.a into the Rust archive, which precedes them on the link line. Cargo does not re-key it on a change of the bundled objects, so it kept OpenSSL objects that still have a PC table.
c Fix matches root cause? Yes. OPENSSL_LIBS is empty, so no copy is bundled and OpenSSL comes from OpenSSL::SSL/OpenSSL::Crypto. No link-order or cache workaround.
d Test intent preserved / new tests added? CMake-only change, no in-tree test. The oracle is libFuzzer's own startup check, which the weekly corpus minimization and nightly libFuzzer jobs run.
e Both directions demonstrated? Same tree: stale build 6e1036b1 has a PC table and exits 1 with the CI error; fixed build 20231aa6 has none and exits 0 (also -merge=1 and 60 s of fuzzing).
f Fix is general across code paths? delta_kernel_ffi is the only openssl-sys user that links ClickHouse's OpenSSL; the other Rust archives contain no C objects.
g Fix generalizes across inputs (params/datatypes/wrappers)? Every fuzzer that links dbms gets OpenSSL this way (2 measured); the debug binary links one OpenSSL, 3.5.8.
h Backward compatible? (maintainer-approved exception only) Yes. No settings, formats or on-disk changes.
i Invariants and contracts preserved? One OpenSSL in the binary, built from contrib/openssl with the current flags: one OpenSSL_version_num definition, no OpenSSL objects in the Rust archive, and the delta-lake stateless tests pass.

Session id: cron:clickhouse-impl-slot-5:20261004-170800

@groeneai
groeneai requested review from azat and thevar1able October 4, 2026 19:24
@clickhouse-gh

clickhouse-gh Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2132b45]

Summary: ✅


AI Review

Summary

This PR changes delta_kernel_ffi so openssl-sys stops embedding libssl.a and libcrypto.a into libdelta_kernel_ffi.a, leaving OpenSSL to come from the existing CMake-linked OpenSSL::SSL / OpenSSL::Crypto targets instead. I did not find a correctness or compatibility problem in the change itself: the pinned openssl-sys version used by the delta-kernel-rs submodule explicitly treats OPENSSL_LIBS= as “emit no cargo:rustc-link-lib directives”, corrosion_set_env_vars preserves an empty KEY= value unchanged, and all in-tree consumers link ch_rust::delta_kernel_rs via CMake targets rather than by bypassing its interface dependencies.

Missing context / blind spots
  • ⚠️ The broad build/fuzzer matrix was still pending at review time. Fast test, Style check, and Build (arm_tidy) had finished, but the most relevant follow-up evidence is still a completed build/fuzzer job confirming the final binaries link cleanly across the remaining configurations.
Final Verdict
  • Status: ✅ Approve
  • No code changes requested from review. Let the remaining CI matrix finish before merge for the final end-to-end confirmation.

LLVM Coverage Report

Measured on commit 2132b45.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.60% 79.70% +0.10%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +239 lines in 60 files (-82 lines lost coverage) · Details

Full report

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement submodule changed At least one submodule changed in this PR. labels Oct 4, 2026
@thevar1able thevar1able self-assigned this Oct 4, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. label Oct 4, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 2132b4584 with master a96b46024 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 6721cae0d; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov added the blocker This issue / pr blocks a new release label Oct 4, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 4, 2026
Merged via the queue into ClickHouse:master with commit c07ba36 Oct 4, 2026
149 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release can be tested Allows running workflows for external contributors comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants