Skip to content

Unpoison fiber stack after context switch on AArch64#46

Open
alexey-milovidov wants to merge 2 commits intoclickhouse-1.90.0from
fix-msan-fiber-aarch64-padding
Open

Unpoison fiber stack after context switch on AArch64#46
alexey-milovidov wants to merge 2 commits intoclickhouse-1.90.0from
fix-msan-fiber-aarch64-padding

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

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, triggering false positives in
unrelated code.

Fix by calling __msan_unpoison on the whole fiber stack after every
__msan_finish_switch_fiber on AArch64. The main_ctx guard ensures we
only unpoison fiber stacks, not the main thread stack.

See ClickHouse/ClickHouse#102305 for the corresponding main repo PR.

alexey-milovidov added a commit to ClickHouse/ClickHouse that referenced this pull request Apr 10, 2026
Point to ClickHouse/boost#46 which adds __msan_unpoison after every
fiber context switch on AArch64, fixing MSan false positives caused by
struct-padding shadow accumulation on fiber stacks (STID 1478-2063).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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, triggering false positives in unrelated code.

Unpoison the entire fiber stack after each __msan_finish_switch_fiber
to clear accumulated dirty padding shadow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexey-milovidov alexey-milovidov force-pushed the fix-msan-fiber-aarch64-padding branch from c0df245 to a6da369 Compare April 10, 2026 06:38
@alexey-milovidov alexey-milovidov changed the base branch from msan-context-fibers-support to clickhouse-1.90.0 April 10, 2026 06:38
The AArch64 fiber stack unpoison code uses `__msan_unpoison` but it was
not declared in the extern "C" block alongside the other MSan functions.
This caused a build failure on arm_msan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant