Skip to content

fix(coalesce): add Acquire fence after Arc::strong_count in orphan cleanup - #493

Open
biaoma-ty wants to merge 1 commit into
apache:mainfrom
biaoma-ty:fix/coalesce-orphan-acquire-fence
Open

biaoma-ty wants to merge 1 commit into
apache:mainfrom
biaoma-ty:fix/coalesce-orphan-acquire-fence

Conversation

@biaoma-ty

Copy link
Copy Markdown
Contributor

Summary

  • Add an Acquire fence after observing Arc::strong_count(&entry) == 2 and before re-checking entry.cell.initialized() in EntryTable::cleanup_abandoned_entry.
  • Add a multi-threaded regression test in tests-integration/tests/once_map_test.rs exercising concurrent waiter cancellation against entry publication.
  • Record the fix in CHANGELOG.md.

Design Notes

EntryGuard::drop skips locking the entry table once entry.cell.initialized() is observed and releases its Arc directly with Release ordering. Meanwhile, a cancelled caller that dropped its OnceState wait before publication may acquire the table lock and inspect Arc::strong_count(&entry) (which uses Ordering::Relaxed) followed by entry.cell.initialized(). Without an intervening Acquire fence, observing strong_count == 2 does not synchronize with the publisher's Arc::drop on weakly ordered architectures, allowing initialized() to read false and evict a completed OnceMap entry.

This branch has not been deployed

No deployments
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