Skip to content

Add MSan support for fibers#101621

Draft
azat wants to merge 1 commit intoClickHouse:masterfrom
azat:msan-fibers
Draft

Add MSan support for fibers#101621
azat wants to merge 1 commit intoClickHouse:masterfrom
azat:msan-fibers

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Apr 2, 2026

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Add MSan support for fibers

I've looked at github, and there are 0 usage of __msan_start_switch_fiber/__msan_finish_switch_fiber outside of LLVM - https://github.com/search?q=%22__msan_start_switch_fiber%22++-path%3A%22compiler-rt%22+-path%3A%22msan_interface.h%22+-path%3A%22msan%2Fmsan.cpp%22+-path%3A%22msan_interface_internal.h%22+-path%3A%22swapcontext_annotation.cpp%22+&type=code&ref=advsearch

So either it is a problem in other places, or it is not mandatory

Also I've tried to reproduce the issue with simple fibers, w/o any luck, but probably this is what we are hitting here.

Refs: ClickHouse/boost#45
Reverts: #100138
Closes: #101566

@azat azat requested a review from alexey-milovidov April 2, 2026 13:32
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Apr 2, 2026

Workflow [PR], commit [67a66cd]

Summary:

job_name test_name status info comment
Stress test (arm_msan) failure
Server died FAIL cidb
MemorySanitizer: use-of-uninitialized-value (STID: 1003-358c) FAIL cidb, issue

AI Review

Summary

This PR updates fiber/MSan integration by enabling BOOST_USE_MSAN for _boost_context, updating the Boost submodule to a commit that adds proper MSan fiber-switch hooks, and removing local __msan_unpoison from FiberStack::allocate. The change is small, targeted, and consistent with upstream sanitizer integration; I did not find correctness, safety, or performance issues in the touched paths.

Missing context
  • ⚠️ No CI report links or run results were provided in this review context, so runtime validation under MSan could not be verified here.
ClickHouse Rules
Item Status Notes
Deletion logging
Serialization versioning
Core-area scrutiny
No test removal
Experimental gate
No magic constants
Backward compatibility
SettingsChangesHistory.cpp
PR metadata quality
Safe rollout
Compilation time
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh bot added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels Apr 2, 2026
@azat
Copy link
Copy Markdown
Member Author

azat commented Apr 2, 2026

So either it is a problem in other places, or it is not mandatory

Though the example from LLVM clearly reproduce a bug, though it has manual assertion - https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/msan/Linux/swapcontext_annotation.cpp

# with __msan* commented out
$ clang -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -fsanitize=memory -o /tmp/test compiler-rt/test/msan/Linux/swapcontext_annotation.cpp
$ /tmp/test
main: swapcontext to fiber
fiber: entering fiber
test: compiler-rt/test/msan/Linux/swapcontext_annotation.cpp:27: void (anonymous namespace)::fiber(): Assertion `previous_stack_bottom != nullptr' failed.
Aborted                    /tmp/test

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Apr 2, 2026

LLVM Coverage Report

Metric Baseline Current Δ
Lines 78.00% (685,718/879,053) 84.10% (738,993/879,052) +6.10% (+53,275)
Functions 90.40% (794,106/878,414) 90.90% (798,243/878,433) +0.50% (+4,137)
Branches 70.60% (220,742/312,660) 76.60% (239,534/312,660) +6.00% (+18,792)

Changed lines: 100.00% (3/3) · Uncovered code

Full report · Diff report

@azat
Copy link
Copy Markdown
Member Author

azat commented Apr 2, 2026

Though actually I'm not sure that this will fix the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant