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

[5.0] Fix issue #2330 by limiting the vector size that can be reserve'd #2405

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

greg7mdp
Copy link
Contributor

Resolves #2330.

The deserialization of arrays involves reading a size, and then the array elements which are emplace'd back into a std::vector. For normal vectors, since we know the size in advance, it is beneficial to call std::vector::reserve() to prevent quadratic reallocations of the vector's buffer as the values are read. Still, limit the size that can be reserved to 1024 fc::variant values, or 16KB since sizeof(fc::variant) == 16).

@greg7mdp greg7mdp requested review from heifner and arhag August 20, 2024 17:33
@heifner heifner requested a review from spoonincode August 20, 2024 17:34
@heifner heifner changed the title Fix issue #2330 by limiting the vector size that can be reserve'd [5.0] Fix issue #2330 by limiting the vector size that can be reserve'd Aug 20, 2024
@arhag arhag linked an issue Aug 20, 2024 that may be closed by this pull request
@greg7mdp greg7mdp merged commit dcbdb86 into release/5.0 Aug 20, 2024
29 checks passed
@greg7mdp greg7mdp deleted the gh_2330_5.0 branch August 20, 2024 18:17
@ericpassmore ericpassmore added the bug Something isn't working label Oct 2, 2024
@ericpassmore
Copy link
Contributor

Note:start
category: Other
component: Internal
summary: Improve deserialization by limiting vector size that can be reserved, prevent erroring out for large data structures.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

abi_tests/abi_large_array test fails with swap space less than 2GB
4 participants