Repository navigation
Do not treat the CFI build as a sanitizer build in the test harnesses - #115591
alexey-milovidov merged 6 commits into
Conversation
…staller tests/config/install.sh classified a build as a sanitizer build by testing CXX_FLAGS LIKE '%-fsanitize=%'. The amd_cfi profile adds -fsanitize=cfi-vcall,cfi-derived-cast (CMakeLists.txt:527), so the substring matched even though -DSANITIZE= is empty. The harness therefore installed config.d/trace_log_no_symbolize.xml, TraceLog stored symbolize = false, and TraceLog.cpp:296-299 inserted a zero-length array into both symbols and lines. That is why 03150_trace_log_add_build_id and 03150_trace_log_source_lines fail under amd_cfi. CFI is a link-time vtable check with no runtime interception of allocation or memory access, so the override's purpose (in-flush symbolization being too slow under sanitizer instrumentation) does not apply to it. Test the build system's own marker instead. cmake/sanitize.cmake:30 puts -DSANITIZER into SAN_FLAGS, which is applied to CMAKE_CXX_FLAGS in all five branches of the if (SANITIZE) block and nowhere else in the tree, and sanitize.cmake:150-152 fails configure if a branch loses it. A hardcoded sanitizer-name list would be a second parser to keep in sync with cmake. Measured on three real binaries: the ASan snapshot still returns 1, the exact amd_cfi artifact from the failing job (build ID e3992b92853623fcc8ebea13060c0d 7603f98201) now returns 0, the debug snapshot is unchanged at 0. End to end, running the real install.sh and the real test files against that artifact: with the reverted script both tests fail (0 1 0 and 0 0, every trace row carrying zero-length arrays), with this change both pass (0 1 1 and 0 1) and real frames appear. Nothing is wrong with symbolization, ThinLTO, CFI codegen, SPLIT_DEBUG_SYMBOLS or BUILD_STRIPPED_BINARY. Official release builds are not affected: amd_cfi and amd_release differ by exactly one flag (ENABLE_CFI versus BUILD_STANDALONE_KEEPER), both carry ENABLE_THINLTO=1, an empty SANITIZE, SPLIT_DEBUG_SYMBOLS=ON and BUILD_STRIPPED_BINARY=1, so ThinLTO with split debug symbols and a stripped binary is the shipped release configuration. Closes: ClickHouse#115122
The note added in the previous commit called CFI a "link-time-only check". CFI requires ThinLTO at link time, but it enforces at runtime: CMakeLists.txt:519-520 documents that a violation executes an illegal instruction (SIGILL) and CI's core-dump handler turns that into a stack trace, and CFI_FLAGS at CMakeLists.txt:527 carries -fno-sanitize-recover=cfi, which is a runtime continue-after-violation policy. The load-bearing invariant is unchanged and is now stated accurately: CFI traps on a bad vcall or cast without linking a sanitizer runtime, so in-flush symbolization is not slowed down and the trace_log_no_symbolize.xml override does not apply. Comment text only. Stripping full-line comments from tests/config/install.sh at the previous commit and at this one yields byte-identical files, so no rebuild or re-validation is required.
Internal second-model review (click to expand)Reviewed cold before reading the implementation notes, then re-reviewed by an independent model
Independently re-derived and confirmed: |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260820-090002 |
|
Workflow [PR], commit [2f1e5f8] Summary: ✅ AI ReviewSummaryThis PR fixes the Final Verdict✅ No new findings. |
|
cc @Algunenano, could you review this? The test harness classified the CFI build as a sanitizer build because it tested CXX_FLAGS for '-fsanitize=', which also matches CFI's cfi-vcall and cfi-derived-cast, so it installed the no-symbolize trace_log override and system.trace_log came back with empty symbols and lines. It now tests for the -DSANITIZER marker that cmake/sanitize.cmake adds only in real sanitizer builds. |
…rness The same misclassification the previous commit fixed in tests/config/install.sh is also present in the integration test harness. is_built_with_sanitizer() with no argument tested for the bare substring "-fsanitize=", which the amd_cfi profile matches: cmake/sanitize.cmake leaves CFI's own -fsanitize=cfi-vcall, cfi-derived-cast in CMAKE_CXX_FLAGS_RELWITHDEBINFO, and cmake/print_flags.cmake concatenates that into the CXX_FLAGS row of system.build_options that this predicate reads. CFI is not a runtime sanitizer. It requires ThinLTO at link time but enforces at runtime by trapping (CMakeLists.txt:519-520, :527), with no sanitizer runtime attached, so an amd_cfi build has release-build performance. The generic check now tests for -DSANITIZER, which cmake/sanitize.cmake:30 puts in SAN_FLAGS and which reaches CMAKE_CXX_FLAGS in all five branches of the if (SANITIZE) block (:35, :107, :115, :131, :141); :145 fails configure for an unknown sanitizer, so there is no sixth branch. cmake/sanitize.cmake:220-224 makes ENABLE_CFI and SANITIZE mutually exclusive, so the two markers cannot co-occur. The named checks keep testing -fsanitize=<name>: is_built_with_address_sanitizer, is_built_with_thread_sanitizer and is_built_with_memory_sanitizer distinguish between sanitizers, which -DSANITIZER cannot, and test_crash_log/test.py:152-155 passes the names through directly. Verified those three are the only non-bare callers, and that their results are unchanged for every build profile. Measured on the real amd_cfi binary from the failing job (build ID e3992b92853623fcc8ebea13060c0d7603f98201) and on an ASan binary as a positive control: the old predicate returned true for both, the new one returns true only for ASan. Exercised the new method body against the CXX_FLAGS rows of nine build profiles (amd_cfi, asan, tsan, msan, ubsan, asan_ubsan, debug, release, coverage); only amd_cfi changes verdict. The visible effect is that under amd_cfi the 50 bare call sites across 35 integration test files no longer skip themselves, which is the point: those guards exist for sanitizer slowness that a CFI build does not have. The one this issue is about is test_trace_log_build_id, which skipped with the reason "trace_log is disabled with sanitizers" even though trace_log is fully enabled under CFI. This cannot be shown green before merge: WeeklyCFI is a scheduled workflow (Mondays 03:00 UTC) and no pull request can run it. Related: ClickHouse#115122
Only WeeklyCFI builds the amd_cfi profile and it is a scheduled workflow, so no pull request can run either of the two predicates this pull request fixes against a real CFI binary. Both consumers react to the misclassification by skipping work (the functional-test installer disables symbolization, integration tests skip themselves), so a revert would stay green and silently restore the bug. The test runs the real is_built_with_sanitizer against the measured CXX_FLAGS rows of nine build profiles, so it fails if the classification regresses. It also asserts that the named address/thread/memory checks stay on -fsanitize=<name>, which -DSANITIZER cannot express, and that CFI's flags do match a bare -fsanitize= test, which is what makes this a live oracle rather than a tautology. The installer assertion is scoped to is_sanitizer_build, since is_fast_build tests the same substring but runs only in the Fast test job, which builds without CFI. Verified it is not vacuous: reverting the helper fails test_non_sanitizer_builds_are_not_detected[amd_cfi], and reverting the installer fails test_installer_gates_symbolization_on_the_same_invariant. It lives in ci/tests because that suite runs on every pull request, while the integration suite requires a running cluster and collects only test_*/test*.py. Related: ClickHouse#115122
Two gaps meant a revert of either predicate could still pass CI. The installer assertion only searched the script's source text, so it also passed for a function that ignores the build flags entirely: a body of `: "'%-DSANITIZER%'"; return 0` contains the new literal and not the old one, while installing the symbolization override for every build. It now runs the installer's own is_sanitizer_build with a stub clickhouse on PATH answering the build_options query, and asserts the exit status that decides whether trace_log_no_symbolize.xml is installed, for all nine build profiles. The CI Tests job's cache digest covered ./ci plus two test-harness files, but neither predicate's file, so a later change touching only tests/config/install.sh or tests/integration/helpers/cluster.py could reuse a green cached result and never run these guards. Both are now digest inputs, the same way clickhouse-test and shell_config.sh already are for the expect-trace guards. Verified against four mutations: reverting the installer to the bare -fsanitize= test fails the amd_cfi arm; making the function unconditionally true fails all four non-sanitizer arms; unconditionally false fails all five sanitizer arms; and reverting the integration helper fails the amd_cfi classification arm. The first of those is the only one the previous text-matching assertion could catch. Related: ClickHouse#115122
The installer guard executed is_sanitizer_build and asserted its exit status, so it covered the classification but not the wiring to the symlink it controls. Rewriting the conditional as `if false && is_sanitizer_build` left every assertion green while no longer disabling symbolization for any sanitizer build. The guard now extracts the function together with the `if` that consumes it, runs that block against a temporary destination directory, and asserts whether trace_log_no_symbolize.xml was linked. That is the state the server actually reads, so it also covers the conditional and the symlink target. Six mutations now redden it: the bare -fsanitize= revert, an unconditionally true predicate, an unconditionally false one, a short-circuited conditional, a symlink pointing at the wrong file, and the integration helper revert. Related: ClickHouse#115122
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units21 translation units recompiled, 220 s compile time in total, 21 of them have a recent master baseline. |
CI finish ledger - 2f1e5f8No check failed at this head: 173 unique checks, 100 success and 73 skipped, 0 failures. The
On coverage, since the skipped count is high: Session id: cron:our-pr-ci-monitor:20260820-210000 |
ClickHouse#115591 fixed ClickHouse#115122: the empty symbols/lines were not a ThinLTO/CFI symbolization problem but the test harness misclassifying the CFI build as a sanitizer build (CXX_FLAGS LIKE '%-fsanitize=%' matches -fsanitize=cfi-vcall,...) and installing trace_log_no_symbolize.xml. Both tests are expected to pass in the WeeklyCFI stateless lanes now, so the comments are obsolete. Co-Authored-By: Claude Fable 5 <[email protected]>
Review comment: the module's private _is_sanitizer_build probed for the bare -fsanitize= substring, which also matches the CFI build's -fsanitize=cfi-vcall,cfi-derived-cast, so started_cluster never created node_smol and test_size_adjustment silently skipped in every Integration tests (amd_cfi, *) run. Use the -DSANITIZER predicate, the same one ClickHouseInstance.is_built_with_sanitizer and tests/config/install.sh use since ClickHouse#115591. The check runs before the cluster starts, so it cannot reuse the ClickHouseInstance method directly. Co-Authored-By: Claude Fable 5 <[email protected]>
With a UBSan check in trap mode, `CXX_FLAGS` of a build without the `SANITIZE` option contains `-fsanitize=`. Fast test would then not install `limits_fast.yaml`, the upgrade check would skip its settings comparison and `test_userspace_page_cache` would skip `test_size_adjustment`. Test `-DSANITIZER`, as `install.sh` and `cluster.py` already do since ClickHouse#115591. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Closes: #115122
Two test harnesses decide whether a build is a sanitizer build by testing
CXX_FLAGS LIKE '%-fsanitize=%'. Theamd_cfiprofile adds-fsanitize=cfi-vcall,cfi-derived-cast(
CMakeLists.txt:527), so the substring matches even though-DSANITIZE=is empty:tests/config/install.sh:227installsconfig.d/trace_log_no_symbolize.xml, soTraceLog.cpp:298-299inserts a zero-length array intosymbolsandlines, failing the two03150_trace_log_*tests.tests/integration/helpers/cluster.py:5152is_built_with_sanitizer()makes 50 no-argument callsites across 35 integration test files skip themselves,
test_trace_log_build_idsaying"trace_log is disabled with sanitizers", which is not true under CFI.
Both now test
-DSANITIZER, whichcmake/sanitize.cmake:30puts intoSAN_FLAGSand which reachesCMAKE_CXX_FLAGSin all 5 branches ofif (SANITIZE)and nowhere else. The namedaddress/thread/memorychecks keep testing-fsanitize=<name>.The reporter's open question is answered, and negatively: official release builds are not
affected.
amd_cfiandamd_releasediffer by exactly one flag (-DENABLE_CFI=1versus-DBUILD_STANDALONE_KEEPER=1), so ThinLTO with split-debug and stripping is already the shippedconfiguration.
Validated on the exact binary from the failing job (build ID
e3992b92...): with the overridepresent both
03150_*tests fail; with the patched script both pass. That binary is now classifiedas not sanitized while a real ASan binary still is, the regression risk this PR's ASan/TSan/MSan
lanes cover.
No existing check can show the
03150_*tests green:WeeklyCFIon master runs only build,integration and stress (
ci/workflows/weekly_cfi.py:30-34), and the statelessamd_cfilane arriveswith #115036, still open. Since both consumers react by skipping work, a revert would stay green, so
ci/tests/test_cfi_not_a_sanitizer_build.pypins both predicates against the measuredCXX_FLAGSofnine profiles, running the installer's own function with a stub
clickhouse. It runs on every PR,and both predicate files are now
CI Testsdigest inputs so a later edit cannot reuse a cached pass.#113107 edits the same block, so whichever lands second may need a rebase.
CI report.
Other users of an
-fsanitizestring test, left unchanged (click to expand)I checked every in-tree consumer of the same "is this a sanitizer build" idea and changed the two
that are reachable under CFI and change test outcomes:
install.sh:92is_fast_buildFAST_TEST=1, whose only producer builds with-DENABLE_THINLTO=0and no CFI, and CFI without ThinLTO is a cmakeFATAL_ERRORtests/clickhouse-test:5135collect_build_flagsSANITIZEDstays false. It must keep the name map to emit per-sanitizerno-asan/no-tsantags, which a boolean marker cannot expresstests/docker_scripts/upgrade_runner.sh:171amd_cfiupgrade jobtests/integration/test_userspace_page_cache/test.py:31ci/jobs/scripts/functional_tests/setup_log_cluster.sh:102Stress test (amd_cfi)also runsinstall.shon master, so that predicate is exercised there, butthat suite asserts nothing about symbolized
trace_log.Each remaining one is a separate question with no observed consequence today, so widening this PR
to them would be unmeasured churn.
Workflow [PR]
Sync PR [sync-upstream/pr/115591]
Version info
26.8.1.1830(included in26.8and later)