Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix incorrect handling of MutexGuard and HashMap removal #21346

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hexcow
Copy link

@hexcow hexcow commented Feb 25, 2025

Description

I noticed an issue where the code wasn't properly handling the removal of an item from the HashMap wrapped in a MutexGuard. The fix ensures that we first acquire the MutexGuard to access the HashMap and then call .remove() on it. This avoids potential issues with concurrent access and ensures the correct behavior.

Changes:

  • Called self.pending(key) to get the MutexGuard wrapping the HashMap.
  • Used .remove() on the HashMap to properly remove the item.
  • Added a check to ensure registrations is not empty before proceeding.

Test plan

  1. Verify that the HashMap removal logic works as expected in a single-threaded context.
  2. Test the fix in a multi-threaded environment to ensure no race conditions occur.
  3. Add unit tests to cover the scenario where registrations is both present and absent.

Release notes

  • Protocol: No changes.
  • Nodes (Validators and Full nodes): No changes.
  • gRPC: No changes.
  • JSON-RPC: No changes.
  • GraphQL: No changes.
  • CLI: No changes.
  • Rust SDK: Fixed incorrect handling of MutexGuard and HashMap removal to ensure thread safety.

Copy link

vercel bot commented Feb 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 25, 2025 11:38am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 25, 2025 11:38am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 25, 2025 11:38am

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.

2 participants