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

docs: specify s2n_blob growable conditions #4943

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

Conversation

jmayclin
Copy link
Contributor

@jmayclin jmayclin commented Dec 3, 2024

Description of changes:

The growable field on s2n_blob does have a purpose, but it took me a lot of investigation to figure out what that purpose was. So I added a comment!

If we ever decide that zero-sized allocation are forbidden, we can remove it.

Testing:

All unit tests should continue to pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jmayclin jmayclin marked this pull request as ready for review December 3, 2024 03:02
@github-actions github-actions bot added the s2n-core team label Dec 3, 2024
utils/s2n_blob.h Outdated
Comment on lines 40 to 42
/* An allocated blob (e.g.`s2n_alloc`) is always growable. A "reference"
* blob (from `s2n_init`) is never growable.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether this behavior was actually intentional 🤔 Kind of seems like it was an artifact of aliasing "s2n_alloc" to "s2n_realloc", probably for unrelated reasons.

Separating "growable" from "allocated" definitely makes sense in the stuffer, because "allocated" indicates whether or not the data needs to be freed, and "growable" indicates whether insufficient space should be an error or lead to an allocation (usually it's an error).

But I guess with a blob, it wouldn't grow automatically, and you'd have to explicitly call "realloc", which is pretty strong indicator that you want to allocate more memory :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, I think "growable" is just a very confusing concept for the blob, and don't understand a scenario where

  1. a stuffer would have growable=false
  2. a blob would have growable=true
    or vice versa.

I opened #4944 to track further "normalization".

utils/s2n_blob.c Outdated Show resolved Hide resolved
@jmayclin jmayclin requested a review from lrstewart December 6, 2024 01:21
utils/s2n_blob.h Outdated Show resolved Hide resolved
stuffer/s2n_stuffer.h Outdated Show resolved Hide resolved
jmayclin and others added 2 commits December 10, 2024 09:28
@jmayclin jmayclin requested a review from maddeleine December 10, 2024 17:30
@jmayclin jmayclin enabled auto-merge December 10, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants