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

Safely handle race condition between isEmpty() and lastKey() being called #8362

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

matthew1001
Copy link
Contributor

@matthew1001 matthew1001 commented Feb 27, 2025

PR description

Safely handle cases where a map's isEmpty() call returns false, but the map is updated before the call to lastKey() is made.

I've looked through the rest of the codebase and fixed the one other place I think we could hit this. For other code paths that use the same combination of isEmpty() and lastKey() I don't think they are likely to suffer from the same issue. If they do the NoSuchElementException will clearly point to where else we need to fix it.

No change log entry as it's just an internal fix that nobody else has reported seeing yet.

Fixed Issue(s)

Fixes #8356

…lled

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

no need to apply the change to the layered txpool, since it is thread safe

matthew1001 and others added 3 commits March 3, 2025 08:31
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
@matthew1001 matthew1001 requested a review from fab-10 March 3, 2025 08:44
@matthew1001 matthew1001 enabled auto-merge (squash) March 3, 2025 16:10
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.

eth_getTransactionCount() can cause java.util.NoSuchElementException
2 participants