forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 303
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
accounts-db: throw error explicitly for next_account_offset calculation when overflows #2093
Merged
mergify
merged 2 commits into
anza-xyz:master
from
HaoranYi:accounts-db/next_account_offset
Jul 12, 2024
Merged
accounts-db: throw error explicitly for next_account_offset calculation when overflows #2093
mergify
merged 2 commits into
anza-xyz:master
from
HaoranYi:accounts-db/next_account_offset
Jul 12, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HaoranYi
changed the title
handle overflow for next_account_offset calculation
accounts-db: handle overflow for next_account_offset calculation
Jul 11, 2024
HaoranYi
force-pushed
the
accounts-db/next_account_offset
branch
3 times, most recently
from
July 11, 2024 20:21
1858a19
to
c301752
Compare
HaoranYi
commented
Jul 11, 2024
HaoranYi
force-pushed
the
accounts-db/next_account_offset
branch
from
July 12, 2024 15:28
863042c
to
6ffcc21
Compare
brooksprumo
reviewed
Jul 12, 2024
brooksprumo
reviewed
Jul 12, 2024
HaoranYi
force-pushed
the
accounts-db/next_account_offset
branch
from
July 12, 2024 18:52
6ffcc21
to
c28a32a
Compare
HaoranYi
commented
Jul 12, 2024
HaoranYi
changed the title
accounts-db: handle overflow for next_account_offset calculation
accounts-db: throw error explicitly for next_account_offset calculation when overflows
Jul 12, 2024
HaoranYi
force-pushed
the
accounts-db/next_account_offset
branch
from
July 12, 2024 19:03
c28a32a
to
ef631e3
Compare
HaoranYi
force-pushed
the
accounts-db/next_account_offset
branch
2 times, most recently
from
July 12, 2024 19:46
5097b80
to
f389dd5
Compare
HaoranYi
force-pushed
the
accounts-db/next_account_offset
branch
from
July 12, 2024 19:48
f389dd5
to
d7714fe
Compare
brooksprumo
reviewed
Jul 12, 2024
…ies offset calc with mmap
brooksprumo
approved these changes
Jul 12, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HaoranYi
added
the
automerge
automerge Merge this Pull Request automatically once CI passes
label
Jul 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
next_account_offset
calculation is not safe, and it assumes that calculation never overflow. If it overflows, the app will crash. Fortunately, this is only an issue for tests and debug tools. For production validator code, we always sanitize the storage when we load. Therefore, we should (hopefully)never hit overflow fornew_account_offset
calculation. However, it would still be nice to throw the error explicitly when we overflow.scan_index
. And the current test coverage doesn't cover corner cases.Summary of Changes
next_account_offset
.scan_index
with the corner cases, such incomplete account's data and garbage data that cause overflow. (now split into Accounts-db: Add scan tests to cover bad accounts storage files #2123)test_scan_pubkey
to cover mroe corner cases (now split into Accounts-db: Add scan tests to cover bad accounts storage files #2123).Fixes #