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

Check capacity of vector before resizing #805

Closed
wants to merge 1 commit into from

Conversation

Jrigada
Copy link
Contributor

@Jrigada Jrigada commented Feb 1, 2023

Check capacity of vector before resizing

Description

PR to solve the issue reported by Patrick from Fuzzing Labs
#798

Description of the pull request changes and motivation.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

if segment.len() <= value_offset {
if (segment.capacity() + value_offset + 1) * mem::size_of::<MaybeRelocatable>()
Copy link
Contributor

Choose a reason for hiding this comment

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

This will overflow if the condition is true. I'm personally not sure it's valuable to catch this case, and certainly I don't think this is the proper place to fix it. Instead, we should make sure offsets in relocatables don't exceed 47 bits, which is how big they're specified to be.

Copy link
Contributor

@fmoletta fmoletta Feb 2, 2023

Choose a reason for hiding this comment

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

+ 1

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll fix this by using try_reserve in a different PR. It should be cleaner and more robust, while also avoiding other possible points of failure (it might still fail to allocate and panic as it's implemented).
I'll refer to this PR and close it when ready.

@Jrigada Jrigada marked this pull request as draft February 13, 2023 10:49
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.

3 participants