Skip to content

fix: add acquire fence in bthread_join for ARM memory visibility#3276

Open
guoliushui wants to merge 2 commits intoapache:masterfrom
guoliushui:fix_bthread_join_memory_alignment
Open

fix: add acquire fence in bthread_join for ARM memory visibility#3276
guoliushui wants to merge 2 commits intoapache:masterfrom
guoliushui:fix_bthread_join_memory_alignment

Conversation

@guoliushui
Copy link
Copy Markdown

Ensure memory visibility on ARM architecture after thread join.

What problem does this PR solve?

Issue Number: fix #3274

Problem Summary:

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Ensure memory visibility on ARM architecture after thread join.
@guoliushui
Copy link
Copy Markdown
Author

已使用测试程序验证生效

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses weak-memory-ordering visibility issues where bthread_join() may return before the joining thread can reliably observe the joined bthread’s prior memory writes (reported on ARM/aarch64).

Changes:

  • Add an acquire fence after TaskGroup::join() observes the joined bthread has advanced version_butex.
  • Gate the fence with ARM architecture preprocessor checks (__aarch64__ / __arm__).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bthread/task_group.cpp Outdated
@guoliushui
Copy link
Copy Markdown
Author

guoliushui commented Apr 21, 2026 via email

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.

bthread_join lacks acquire fence on ARM, causing stale reads of joined bthread's memory writes

2 participants