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

core: fix double-readlock in validator #26053

Merged
merged 1 commit into from
Jun 20, 2022

Conversation

BurtonQin
Copy link
Contributor

Problem

There is a possible deadlock caused by double readlock in fn Validator::new.

bank_forks: Arc<RwLock<BankForks>>

The first readlock is on L705 and the second on L706

block_commitment_cache.initialize_slots(
bank_forks.read().unwrap().working_bank().slot(),
bank_forks.read().unwrap().root(),
);

For more details on this kind of deadlock, see
https://www.reddit.com/r/rust/comments/urnqz8/different_behaviors_of_recursive_read_locks_in/

Summary of Changes

Call readlock once and reuse it. After the call, drop the guard.

Fixes #

@mergify mergify bot added the community Community contribution label Jun 18, 2022
@mergify mergify bot requested a review from a team June 18, 2022 09:08
@nikhayes
Copy link

Did you use your tool here to find these? https://github.com/BurtonQin/lockbud

@BurtonQin
Copy link
Contributor Author

Did you use your tool here to find these? https://github.com/BurtonQin/lockbud

Yes.

@jstarry jstarry added the automerge Merge this Pull Request automatically once CI passes label Jun 20, 2022
@mergify mergify bot merged commit 611d2ec into solana-labs:master Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants