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 a main-thread assertion in the QuorumIntersectionChecker #4262

Merged
merged 2 commits into from Mar 29, 2024

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Mar 27, 2024

Change #4240 introduced a new call to assertThreadIsMain(); in the QI constructor. This is correct for the top-level QI checker, but we then run that QI checker on a background thread and, if it does enjoy intersection, we call getIntersectionCriticalGroups which then constructs a pile of QI checkers on the background thread.

The assertion only exists to guard access to the global PRNG to get a seed (the seed used here is a very light requirement that just helps perturb the algorithm's set-splitting path). So a simple solution is to not access the global PRNG in the constructor, but to access it in the scope outside and pass-in a seed. It's harmless to use the same seed in all the sub-checkers constructed in getIntersectionCriticalGroups, so I do that here.

cc @SirTyson

@graydon graydon requested a review from SirTyson March 27, 2024 21:54
Copy link
Contributor

@SirTyson SirTyson left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I'm wondering if we should wrap gRandomEngine in a light weight class that just checks if the current thread is main on access, it seems pretty easy to accidentally call it from a background thread as it currently stands. A refactor for another day though.

@marta-lokhova
Copy link
Contributor

r+ 68b7f8a

@latobarita latobarita merged commit ededc67 into stellar:master Mar 29, 2024
15 checks passed
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.

None yet

4 participants