Skip to content

DO NOT MERGE: ASan heap corruption repro — plain master, without distributed queries - #107160

Closed
davenger wants to merge 2 commits into
masterfrom
corruption-repro-without-distributed
Closed

davenger wants to merge 2 commits into
masterfrom
corruption-repro-without-distributed

Conversation

@davenger

Copy link
Copy Markdown
Member

Related: #107122

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Draft, never to be merged: a CI reproduction setup for the ASan heap corruption (sanitizer_allocator_secondary.h:200 CHECK) that #107122 attributed to the distributed-query infrastructure. CI history suggests the corruption predates #106020: similar reports exist from Nov 2025 (AST fuzzer on master), March 2026 (an unrelated PR), and May 2026 (the Parquet-parallelism PR) — all without the distributed feature.

This PR is plain master without the distributed-query feature, plus two settings that make the corruption more likely to fire and easier to diagnose:

  • max_thread_pool_free_size = 16 for sanitizer test configs — destroys idle threads much more aggressively than the value that triggered the June 10 failures.
  • A large ASan quarantine (quarantine_size_mb=2048) with deeper stack capture — freed memory stays poisoned longer, so a stray write into it produces a heap-use-after-free report with full stacks instead of silently corrupting reused memory.

There is a second PR with the same two settings on top of the #107146 branch (with the distributed feature). If sanitizer jobs crash in both PRs, the corruption lives in shared infrastructure and #106020 is exonerated. If they crash only in the other PR, the feature is implicated — and the quarantine setting should produce a report naming the buggy code, which the #107122 reports could not.

🤖 Generated with Claude Code

@clickhouse-gh

clickhouse-gh Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2a79b33]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6) FAIL
test_storage_s3_queue/test_6.py::test_ordered_mode_with_regex_partitioning[S3Queue-4-1-2] FAIL cidb
test_s3_cluster/test.py::test_cluster_format_detection FAIL cidb
test_s3_cluster/test.py::test_cluster_default_expression FAIL cidb
test_s3_cluster/test.py::test_hive_partitioning[False-0] FAIL cidb
test_s3_cluster/test.py::test_hive_partitioning[False-1] FAIL cidb
test_s3_cluster/test.py::test_hive_partitioning[True-0] FAIL cidb
test_storage_s3_queue/test_6.py::test_ordered_mode_with_regex_partitioning[S3Queue-4-16-1] FAIL cidb
test_s3_cluster/test.py::test_hive_partitioning[True-1] FAIL cidb
test_storage_s3_queue/test_6.py::test_ordered_mode_with_regex_partitioning[S3Queue-4-16-2] FAIL cidb
test_storage_s3_queue/test_6.py::test_ordered_mode_with_regex_partitioning[AzureQueue-0-1-1] FAIL cidb
10 more test cases not shown
Stress test (arm_msan) FAIL
Segmentation fault (STID: 4348-2010) FAIL cidb
Integration tests (amd_asan_ubsan, db disk, old analyzer, 4/6) ERROR

AI Review

Summary

This PR adds diagnostic sanitizer defaults and test configuration to amplify an ASan heap corruption reproducer. The diagnostic scope is too broad: it changes global compiled ASan defaults and installs thread trimming across every sanitizer build, so failures or OOMs become ambiguous rather than proving the intended hypothesis.

Missing context / blind spots
  • ⚠️ The fetched PR CI report currently shows no failed jobs, so there is no CI evidence yet that these knobs reproduce the allocator corruption. A failing ASan report with stacks from the intended job would close this gap.
Findings

⚠️ Majors

  • [base/base/sanitizer_options.h:21] The PR promises targeted ASan diagnostics, but __asan_default_options is linked into every ASan ClickHouse executable. A quarantine_size_mb=2048 default affects the server, clickhouse-client, clickhouse-local, and helper processes in sanitizer jobs; retaining up to 2 GiB of freed chunks per process can turn the reproduction into cgroup OOM failures without a sanitizer report. Keep this opt-in through the repro job's ASAN_OPTIONS or another targeted CI knob.
  • [tests/config/install.sh:170] The trim config is installed for every -fsanitize= build, but the PR contract is an ASan allocator-corruption reproducer. Lowering max_thread_pool_free_size also changes TSan/MSan/UBSan jobs, where the overhead and failure modes are different and can create unrelated sanitizer noise. Make the predicate ASan-specific, for example by checking for sanitize=address, or gate the config behind an explicit repro flag.
Tests
  • ⚠️ Missing diagnostic evidence: current CI did not show ASan heap corruption with full stacks. Before using this as evidence for or against the related distributed-query hypothesis, rerun a targeted ASan job and attach the sanitizer report.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: scope the ASan quarantine and thread trimming to the intended repro run or ASan-only environment, and provide a targeted ASan report showing the diagnostic signal.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 11, 2026
return "halt_on_error=1 abort_on_error=1";
/// Large quarantine keeps freed memory poisoned longer so a wild write is reported as
/// heap-use-after-free with full stacks instead of corrupting recycled allocations silently.
return "halt_on_error=1 abort_on_error=1 quarantine_size_mb=2048 malloc_context_size=30";

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.

__asan_default_options is linked into every ASan ClickHouse executable, so this makes a 2 GiB quarantine the default for all ASan processes, not just the diagnostic CI run. In stateless/flaky/integration jobs this can affect the server, clickhouse-client, clickhouse-local, and bridge/helper processes; retaining up to 2 GiB of freed chunks per process can turn the intended heap-use-after-free reproduction into cgroup OOM failures without a sanitizer report, which weakens the PR's diagnostic signal. Please keep this opt-in through the repro job's ASAN_OPTIONS or another targeted CI knob instead of changing the global compiled default.

Comment thread tests/config/install.sh
}
if is_sanitizer_build; then
ln -sf $SRC_PATH/config.d/trace_log_no_symbolize.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/thread_pool_trim.xml $DEST_SERVER_PATH/config.d/

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.

This installs thread_pool_trim.xml for every -fsanitize= build, but the PR contract is an ASan allocator-corruption reproducer. Lowering max_thread_pool_free_size forces extra OS-thread teardown under TSan/MSan/UBSan too, where the overhead and failure modes are different; failures there will not distinguish the ASan heap-corruption hypothesis from unrelated sanitizer noise. Please make this predicate ASan-specific, e.g. check for sanitize=address, or gate the trim config behind an explicit repro flag.

@davenger davenger added the ci-force-all Do not skip any jobs when running label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-force-all Do not skip any jobs when running pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant