Skip to content

Bump contrib/boost to fix AArch64 MSan fiber-switch false positives (STID 4348-2010) - #110152

Merged
thevar1able merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/bump-boost-msan-fiber-aarch64-unpoison
Jul 20, 2026
Merged

thevar1able merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/bump-boost-msan-fiber-aarch64-unpoison

Conversation

@groeneai

@groeneai groeneai commented Jul 12, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement

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

Fix false-positive MemorySanitizer reports (spurious crash at boost::context::fiber::resume) during boost fiber context switches on AArch64.

Description

Bumps contrib/boost from f05991c to 24df31b, a clean fast-forward pulling two boost-fork commits authored by @ alexey-milovidov on branch fix-msan-fiber-aarch64-padding:

  • a6da369 Unpoison fiber stack after context switch on AArch64
  • 24df31b Add missing __msan_unpoison declaration to externc.hpp

Diff is 18 lines, entirely inside #if defined(BOOST_USE_MSAN) + #if defined(__aarch64__), so it affects only AArch64 MSan builds; all other builds are byte-identical.

Root cause: on AArch64 LLVM loses MSan shadow for struct-padding bytes in return values (llvm/llvm-project#54476). On heap-allocated fiber stacks the dirty shadow accumulates across boost::context switches and propagates via stack-slot reuse, producing spurious "use-of-uninitialized" faults inside unrelated code at __msan_finish_switch_fiber / boost::context::fiber::resume(). The fix unpoisons the whole fiber stack after each switch.

This is the arm_msan-exclusive Segmentation fault (STID: 4348-2010) in the RemoteQueryExecutorReadContext async read fiber that @ alexey-milovidov asked to investigate on #110073. CIDB: 11 hits over 90 days, all on Stress test (arm_msan) (master 2026-06-10 plus 10 unrelated PRs), zero on any other arch/sanitizer, matching the AArch64-MSan-only mechanism above. Investigation and cross-arch verification are tracked in #110124.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110073&sha=f75f6b4383cd713bb07ad345f879953ae276e50e&name_0=PR&name_1=Stress%20test%20%28arm_msan%29

The fix commits are @ alexey-milovidov's own; this PR only lands them by bumping the submodule pin. Verification is via arm_msan CI (no local aarch64-MSan repro environment is available on x86 runners).

Closes #110124

Version info

  • Merged into: 26.7.1.1235 (included in 26.7 and later)

Pulls two boost-fork commits (a6da369, 24df31b) that fix false-positive
MemorySanitizer reports during boost::context fiber switches on AArch64.

On AArch64, LLVM loses MSan shadow for struct-padding bytes in return
values (llvm/llvm-project#54476). On heap-allocated fiber stacks the dirty
shadow accumulates across context switches and propagates via stack-slot
reuse, surfacing as a spurious SIGSEGV/use-of-uninitialized at
boost::context::fiber::resume() (finish_switch_fiber). This is the
STID 4348-2010 arm_msan-only crash in the RemoteQueryExecutorReadContext
async read fiber. The fix unpoisons the whole fiber stack after each
__msan_finish_switch_fiber, guarded to __aarch64__ MSan builds only.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? No local repro possible: crash is arm_msan-EXCLUSIVE (CIDB: all 11/90d on Stress test (arm_msan), 0 on any other arch/sanitizer) and this fleet is x86_64; no aarch64-MSan lane. Per the no-speculative-fix rule this is surfaced as the maintainer's own already-written, root-cause-targeted fix, not a novel guess.
b Root cause explained? Yes. AArch64 loses MSan shadow for struct-padding bytes in return values (llvm/llvm-project#54476); on heap fiber stacks the dirty shadow accumulates across boost::context switches and propagates via stack-slot reuse, faulting at __msan_finish_switch_fiber / resume().
c Fix matches root cause? Yes. Unpoisons the whole fiber stack after each __msan_finish_switch_fiber, clearing the accumulated dirty shadow at its source.
d Test intent preserved / new tests? N/A (contrib submodule bump; verified by existing arm_msan Stress CI, which is where the signature manifests).
e Demonstrated both directions? Not locally (no aarch64-MSan environment). arm_msan CI on this PR is the fails-without/passes-with check.
f General, not a narrow patch? Yes. Fix is in the boost fiber-switch primitive, so it covers every boost::context fiber on AArch64 MSan, not just the RemoteQueryExecutorReadContext read fiber.
g Generalizes across inputs/types? Yes. Stack-level unpoison is independent of the fiber's payload; applies to all three switch sites in fiber_ucontext.hpp.
h Backward compatible? Yes. Entirely inside #if defined(BOOST_USE_MSAN) + #if defined(aarch64); all non-AArch64-MSan builds are byte-identical.
i Invariants/contracts preserved? Yes. __msan_unpoison only clears shadow (marks bytes initialized) on the fiber's own stack region after the switch completes; no control-flow, lifetime, or data change.

Session id: cron:clickhouse-worker-slot-0:20260712-130600

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7156435]

Summary: ✅


AI Review

Summary

This PR bumps contrib/boost from f05991c to 24df31b to import two Boost fork commits that add AArch64 MSan stack unpoisoning in boost::context::fiber_ucontext.hpp and the matching __msan_unpoison declaration. I did not find a new correctness or integration bug in the current code: ClickHouse does route sanitizer builds through BOOST_USE_UCONTEXT, so the imported fiber_ucontext path is the one arm_msan actually executes, and the previously raised whole-stack-unpoison concern is an explicit tradeoff the author justified rather than an unaddressed regression.

Missing context / blind spots
  • ⚠️ I could not validate the fix with a local AArch64 MSan repro environment, and when I checked the current PR state the matching arm_msan build was still pending. A completed arm_msan CI run that exercises the original STID: 4348-2010 path would close the remaining verification gap.
Final Verdict

✅ No new review findings in the current code. The PR looks consistent with its CI Fix or Improvement contract; final confidence depends on the pending arm_msan verification.

@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 Jul 12, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, didn't we fix it a long time ago? What changed?

@groeneai

Copy link
Copy Markdown
Collaborator Author

The April fix answered the general case, not the AArch64 one.

Boost PR #45 "Add MSan support for context/fibers" (merged 2026-04-09 as f05991c, the current contrib/boost pin) added the __msan_start_switch_fiber / __msan_finish_switch_fiber annotations so MSan tracks shadow across fiber context switches. That is what keeps x86 MSan clean.

It does not cover the AArch64-specific problem: LLVM loses MSan shadow for struct-padding bytes in return values (llvm/llvm-project#54476), and on heap fiber stacks that dirty shadow accumulates across switches and propagates via stack-slot reuse, faulting at resume(). The AArch64 follow-up was written the next day (2026-04-10) on the boost-fork branch fix-msan-fiber-aarch64-padding: a6da369 (unpoison the whole fiber stack after each __msan_finish_switch_fiber, guarded by __aarch64__) and 24df31b (add the missing __msan_unpoison decl). Those two commits were never merged into the boost-fork master, so they never reached ClickHouse; the pin has stayed at f05991c.

This PR just picks them up: a clean fast-forward of contrib/boost from f05991c to 24df31b (verified ancestor, only those two commits in between). 18 lines, all under BOOST_USE_MSAN + __aarch64__, so every other build is byte-identical. Nothing was un-fixed; the AArch64 half of the fix simply had not landed.

Comment thread contrib/boost Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

Confirmed: the unpoison covers the whole resumed fiber stack (current()->stack_size) on every AArch64 switch, so an uninitialized local kept live across a yield would have its shadow cleared and stop reporting on arm_msan. The bot's read is correct in principle.

Two things narrow how bad it is in practice:

  • It fires only under BOOST_USE_MSAN && __aarch64__ and only for non-main fiber contexts (!current()->main_ctx), i.e. exactly the fiber-switch path. Every other build is byte-identical.
  • The whole-stack scope is deliberate, not lazy: per the commit's own note the MemorySanitizer reports false positive for uninitialized values in padding llvm/llvm-project#54476 padding contamination is not confined to one site, it propagates via stack-slot reuse, so a narrow "just the return-value padding" unpoison wouldn't reliably kill the false positive. That's the tradeoff being made.

The alternative today is the hard SIGSEGV at resume() (STID 4348-2010, 11/11 hits on Stress test (arm_msan)), which hides ALL signal on the lane, not just the across-yield case.

These two commits are @alexey-milovidov's own (boost-fork fix-msan-fiber-aarch64-padding); this PR only lands them via the submodule bump, so the design call is his. Options: (a) accept the tradeoff as-is (stress lane, alternative is a crash); (b) narrow the unpoison region if a reliable target exists despite the slot-reuse propagation; (c) add a focused arm_msan repro that keeps a genuinely uninitialized local alive across a yield to bound the false-negative window. @alexey-milovidov which do you prefer?

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 729886a

Every failure below has an owner. This PR is an 18-line contrib/boost bump gated entirely to #if defined(BOOST_USE_MSAN) && defined(__aarch64__), so every non-aarch64-MSan build (amd_tsan, amd_asan_ubsan) is byte-identical to master — none of the failures below can be caused by this diff.

Check / test Reason Owner / fixing PR
Integration tests (amd_tsan, 1/6) / test_parallel_replicas_protocol::test_split_topology_rolling_upgrade flaky (30d: 2 PRs, 0 master; boost bump cannot affect amd_tsan) a fix task is created (investigating at full effort — fixing PR link to follow here)
Stateless (amd_asan_ubsan, distributed plan, parallel) / Server died + OOM in dmesg host-OOM (dmesg OOM kill; 14d: 34 hits/19 PRs/3 master) a fix task is created (investigating at full effort — fixing PR link to follow here)

Session id: cron:our-pr-ci-monitor:20260712-210000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for test_split_topology_rolling_upgrade created: #110184

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for amd_asan_ubsan distributed-plan host-OOM created: #110185

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jul 20, 2026
@alexey-milovidov alexey-milovidov added can be tested Allows running workflows for external contributors and removed can be tested Allows running workflows for external contributors labels Jul 20, 2026
@clickhouse-gh clickhouse-gh Bot added pr-ci and removed pr-build Pull request with build/testing/packaging improvement labels Jul 20, 2026
@thevar1able thevar1able self-assigned this Jul 20, 2026
@thevar1able
thevar1able added this pull request to the merge queue Jul 20, 2026
Merged via the queue into ClickHouse:master with commit 3bf011a Jul 20, 2026
350 of 351 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 20, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…t-msan-fiber-aarch64-unpoison

Bump contrib/boost to fix AArch64 MSan fiber-switch false positives (STID 4348-2010)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-ci 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.

Segmentation fault in RemoteQueryExecutorReadContext async fiber resume during shutdown/timeout (STID: 4348-2010)

4 participants