Skip to content

Leave the SanitizerCoverage PC table out of the fuzzer build - #123738

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-fuzzer-relocation-overflow
Oct 4, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-fuzzer-relocation-overflow

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Related: #119039
Related: #121371

Build (amd_fuzzers) has failed on master since 4127c65. It fails at the link step of clickhouse_fuzzer:

ld.lld-22: error: .../libclang_rt_asan.a(sanitizer_stackdepot.cpp.o):(function __sanitizer::(anonymous namespace)::CompressThread::NewWorkNotify(): .text+0x19e): relocation R_X86_64_PC32 out of range: 2148873898 is not in [-2147483648, 2147483647]; references section '.bss'

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=501d978d7b9daa2036adbf79f930fae5db42219c&name_0=MasterCI&name_1=Build%20%28amd_fuzzers%29

This is the same overflow as in #119039. The image sits right at the 2 GiB reach of the small code model, so any commit can tip it over (here #121371 did). Shaving another few MiB would only postpone the next failure. Instead, this removes the largest thing in that range that the fuzzers don't need.

-fsanitize=fuzzer-no-link implies -fsanitize-coverage=pc-table, which emits 16 bytes per instrumented edge into __sancov_pcs. That section is writable, so lld places it between .text and .bss. I compiled KeyCondition.cpp, InterpreterSelectQuery.cpp and FunctionsConversion.cpp with the CI flags. The table is 20-25% of the instrumented .text, which should be several hundred MiB for the whole image. With -fno-sanitize-coverage=pc-table, .text and __sancov_cntrs stay the same and __sancov_pcs is gone.

libFuzzer gets its coverage feedback from the inline 8-bit counters. The PC table only serves reporting (cov: in the progress lines, NEW_FUNC, -print_pcs, -print_coverage, -print_funcs) and -focus_function, and CI uses none of these. ft: stays in the progress lines, and libfuzzer_test_check.py already treats cov as optional.

PIC/PIE doesn't help here because the build already uses both: x86-64 PIC still reaches data with 32-bit RIP-relative relocations. -mcmodel=large would remove the limit, but it would have to cover every object in the image, including Rust crates and sanitizer runtimes, and it makes the code larger and slower.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

🤖 Generated with Claude Code


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

Version info

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

`Build (amd_fuzzers)` on master fails again at the link step of
`clickhouse_fuzzer`, starting with 4127c65 (#121371):

    ld.lld-22: error: .../libclang_rt_asan.a(sanitizer_stackdepot.cpp.o):(function
    __sanitizer::(anonymous namespace)::CompressThread::NewWorkNotify(): .text+0x19e):
    relocation R_X86_64_PC32 out of range: 2148873898 is not in
    [-2147483648, 2147483647]; references section '.bss'

This is the same overflow as in e56a18c: the image sits right at the 2 GiB
reach of the small code model, and any commit can tip it over. Shaving a few
MiB again would only postpone the next failure, so remove the largest thing in
that range that the fuzzers do not need.

`-fsanitize=fuzzer-no-link` implies `-fsanitize-coverage=pc-table`, which
emits 16 bytes per instrumented edge into `__sancov_pcs`. It is a writable
section, so `lld` places it between `.text` and `.bss`. Measured on
`KeyCondition.cpp`, `InterpreterSelectQuery.cpp` and `FunctionsConversion.cpp`
compiled with the CI flags, it is 20-25% of the instrumented `.text`, i.e.
several hundred MiB for the whole image. With `-fno-sanitize-coverage=pc-table`
the `.text` and `__sancov_cntrs` are unchanged and `__sancov_pcs` is gone.

libFuzzer gets coverage feedback from the inline 8-bit counters; the PC table
only serves reporting (`cov:` in the progress lines, `NEW_FUNC`, `-print_pcs`,
`-print_coverage`, `-print_funcs`) and `-focus_function`, none of which CI uses.
`ft:` stays in the progress lines, and the report in `libfuzzer_test_check.py`
already treats `cov` as optional.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=501d978d7b9daa2036adbf79f930fae5db42219c&name_0=MasterCI&name_1=Build%20%28amd_fuzzers%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bcd494c]

Summary: ⏳

job_name test_name status info comment
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) FAIL
05257_sql_security_view_sealed FAIL cidb
04819_dynamic_aggregate_function_state_version FAIL cidb
02884_create_view_with_sql_security_option NOT_FAILED cidb
01513_optimize_aggregation_in_order_memory_long NOT_FAILED cidb

AI Review

Summary

This PR appends -fno-sanitize-coverage=pc-table alongside -fsanitize=fuzzer-no-link in CMakeLists.txt:872, which is the right place to shrink the instrumented object set before every fuzzer link. I did not find a correctness or maintenance issue in the current code: the libFuzzer-only metadata being dropped is not required by the in-tree harness, tests/fuzz/runner.py:39 already parses progress fields generically, ci/jobs/libfuzzer_test_check.py:317 treats cov as optional, and the Praktika report is green, including Build (amd_fuzzers).

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing bcd494c9e with master d3cc829e9 (stripped binary size, per-symbol sizes and ThinLTO time; 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

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems that it should remove move then #122521 and might be enough

We can also switch to arm64, it has 2x more limit (4gib instead of 2gib) - #123749

Wdyt?

Comment thread CMakeLists.txt
get_target_property(target_compile_options ${target} COMPILE_OPTIONS)
if (NOT target_compile_options MATCHES "-fno-sanitize=all")
target_compile_options(${target} PRIVATE "-fsanitize=fuzzer-no-link")
target_compile_options(${target} PRIVATE "-fsanitize=fuzzer-no-link" "-fno-sanitize-coverage=pc-table")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can also exclude some libraries from instrumentation (especially big ones, for which we already even disable debug symbols)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🕵 Good idea, and it would add headroom. I'd keep it as a separate follow-up, though. Excluding a library from -fsanitize=fuzzer-no-link also removes its coverage counters, so libFuzzer can't guide inputs through that code anymore. That trade-off depends on which libraries the fuzzers actually exercise (for example, the big contrib ones like aws, grpc, and arrow are probably safe to drop, while the src/ libraries are not). This PR removes only the PC table, which libFuzzer doesn't use for guidance, so fuzzing behaviour stays the same.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=123738&sha=latest&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%201%2F2%29 (05237_with_expression_alias_scope_descendant, view 10 instead of view 100 under DatabaseReplicated) and provide a fix in a separate PR. If the fix is already in progress, link it here.

The other failures are also unrelated to this CMake-only fuzzer change, and they already have fixes in progress: 04266_text_index_tokens_cardinality_order in #123688 and 05257_sql_security_view_sealed in #123729. I merged master into this branch.

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

The fix is in progress: #123774. The Replicated DDL replay qualified nested, an alias declared inside the WITH expression, with the database, so the view read the table nested (10) instead of the alias (100).

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@azat

Seems that it should remove move then #122521 and might be enough

We can also switch to arm64, it has 2x more limit (4gib instead of 2gib) - #123749

We'll do both and merge as soon as they are green. (The master is blocked; right now, we can merge only already tested PRs. I've also considered trimming the fuzzer build.

We can also: - speed-up CI for "blocker" PRs by omitting most of the checks; - I can merge this change to all my pending PRs so they can merge sooner.

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 comp-build-system Build system (CMake, compilation, platform builds). pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants