Repository navigation
CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build - #109950
Merged
Merged
Conversation
When the CI switched to combined ASan+UBSan builds (SANITIZE=address,undefined), cmake/sanitize.cmake got an explicit branch for the combined value, but the Rust side (contrib/corrosion-cmake) still matched SANITIZE STREQUAL "address" only. Since then the sanitizer CI builds have compiled all Rust code without ASan. Besides losing the instrumentation, this disarmed wasmtime's own ASan guard: without CARGO_CFG_SANITIZE=address its build scripts do not emit --cfg asan, so lazy_per_thread_init installs a per-thread 256 KiB sigaltstack. Its Rust TLS destructor munmaps that stack without sigaltstack(SS_DISABLE), and ASan's UnsetAlternateSignalStack at the same thread's exit then unmaps the same - by that time reused - address range, destroying pages of live heap allocations. This is the source of the sporadic CompressedReadBufferBase::readCompressedData SEGVs on unmapped addresses in ASan CI: the victim is whatever large allocation (usually a read buffer) reuses the freed range between the two munmaps. Root cause established from the decrypted core of the 2026-07-07 occurrence: the faulted buffer was still registered as allocated in the ASan secondary allocator (never freed), exactly one of 2994 live large chunks was damaged, and the destroyed page range measured exactly one wasmtime sigaltstack allocation (guard page + 64*4096 bytes). Verified locally: with SANITIZE=address,undefined the wasmtime build script now emits cargo:rustc-cfg=asan, all Rust crates build with -Zsanitizer=address, the full server links and runs, and executing WASM UDFs no longer allocates the custom signal stack (checked with strace; the mmap(266240) fingerprint is gone while the UDFs keep working). Closes: #104692 Caused by: #99657 Related: ClickHouse/clickhouse-private#63613
Contributor
|
Workflow [PR], commit [39dfbf8] Summary: ✅
AI ReviewSummaryThis PR fixes the Rust-side sanitizer dispatch so Final Verdict
|
Algunenano
approved these changes
Jul 10, 2026
Algunenano
left a comment
Member
There was a problem hiding this comment.
This is a great finding. I think this fixes #106370 but we can keep it open and monitor. I spent quite some time investigating the issue, even looking at rust and specifically wasm multiple times, and did not notice it.
Let's backport it too please
This was referenced Jul 10, 2026
clickhouse-gh Bot
added a commit
that referenced
this pull request
Jul 10, 2026
Backport #109950 to 26.6: CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build
Algunenano
added a commit
that referenced
this pull request
Jul 10, 2026
Backport #109950 to 25.8: CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build
Algunenano
added a commit
that referenced
this pull request
Jul 10, 2026
Backport #109950 to 26.3: CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build
Algunenano
added a commit
that referenced
this pull request
Jul 10, 2026
Backport #109950 to 26.4: CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build
Algunenano
added a commit
that referenced
this pull request
Jul 10, 2026
Backport #109950 to 26.5: CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build
This was referenced Jul 13, 2026
joelynch
pushed a commit
to aiven/ClickHouse
that referenced
this pull request
Aug 17, 2026
…ust in the combined address,undefined build
kewin-robetti
pushed a commit
to viasoftkorp/ClickHouse
that referenced
this pull request
Aug 24, 2026
…ust in the combined address,undefined build
kewin-robetti
pushed a commit
to viasoftkorp/ClickHouse
that referenced
this pull request
Aug 24, 2026
…ust in the combined address,undefined build
kewin-robetti
pushed a commit
to viasoftkorp/ClickHouse
that referenced
this pull request
Aug 24, 2026
…ust in the combined address,undefined build
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…mbined-sanitize CI: Pass -Zsanitizer=address to Rust in the combined address,undefined build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #104692
Caused by: #99657
Related: https://github.com/ClickHouse/clickhouse-private/issues/63613
Related: bytecodealliance/wasmtime#13857
Problem
Sporadic SEGVs at
CompressedReadBufferBase::readCompressedDataon addresses "not mapped to object" keep appearing in ASan CI (#104692) — across unrelated configurations (s3, azure, db disk, with and without distributed cache), on random columns and queries, surviving multiple read-path fixes. Analyzed occurrence: CI report.Additionally, since the switch to combined ASan+UBSan builds all Rust code in sanitizer CI has been silently compiled without any sanitizer.
Root cause
When #99657 switched CI to combined builds (
-DSANITIZE=address,undefined), it added the new value to the C++ flag dispatch incmake/sanitize.cmake:but the Rust flag dispatch in
contrib/corrosion-cmake/CMakeLists.txtwas left matching the old value only:so
-Zsanitizer=addresswas silently lost for theasan_ubsanbuilds. Without it cargo does not exposeCARGO_CFG_SANITIZE=address, wasmtime's build script does not emit--cfg asan, and wasmtime's own ASan guard inlazy_per_thread_init(crates/wasmtime/src/runtime/vm/sys/unix/signals.rs) is disarmed — so it installs a per-thread 256 KiBsigaltstackon every thread that executes a WASM UDF. That stack's TLS destructor munmaps the memory withoutsigaltstack(SS_DISABLE)(upstream bug: bytecodealliance/wasmtime#13857), leaving a dangling kernel registration, and ASan'sUnsetAlternateSignalStackunmaps the same — by then reused — address range at thread exit:The crash stack always belongs to the first reader of the destroyed buffer, never the culprit — for a MergeTree prefetch buffer that first read is
CompressedReadBufferBase::readCompressedData, hence the fixed signature on random victims. Established from the decrypted core of the 2026-07-07 occurrence: the faulted buffer was still registered as allocated in ASan'sLargeMmapAllocator(nofreeinvolved), exactly one of 2994 live large chunks was damaged, and the destroyed page range measured exactly one wasmtime sigaltstack allocation (guard page + 64×4096 bytes).Fix
Match
SANITIZE STREQUAL "address,undefined"in the samecontrib/corrosion-cmakedispatch — the single place where the Rust workspaceRUSTFLAGSare assembled (the MSan/TSan branches live there too).SANITIZE=addressstays supported: the fuzzer build and local pure-ASan builds still pass it. This restores real ASan instrumentation of Rust code and re-arms wasmtime'scfg!(asan)guard, so the custom sigaltstack is not installed at all in ASan builds; the dangling-registration defect itself is reported upstream (bytecodealliance/wasmtime#13857).Verified locally with
SANITIZE=address,undefined: the wasmtime build script emitscargo:rustc-cfg=asanagain, all Rust crates and the full server build and run, and understraceexecuting WASM UDFs no longer allocates the custom signal stack (themmap(266240)fingerprint is gone) while the UDFs keep working.Changelog category (leave one):
Version info
26.7.1.742(included in26.7and later)26.6.2.59,26.5.6.33,26.4.5.121,26.3.17.38,25.8.29.13