Skip to content

buffer: annotate Slice::SizedStorage with counted_by - #47442

Open
LaptopsPlural wants to merge 1 commit into
envoyproxy:mainfrom
LaptopsPlural:buffer-sizedstorage-counted-by
Open

LaptopsPlural wants to merge 1 commit into
envoyproxy:mainfrom
LaptopsPlural:buffer-sizedstorage-counted-by

Conversation

@LaptopsPlural

Copy link
Copy Markdown

Description

Slice::SizedStorage is the true alloc-capacity pair for Slice backend storage (mem_ points at len_ bytes). This change:

  • Represents mem_ as uint8_t* so Clang’s counted_by can describe the bound (the attribute applies to raw pointers, not std::unique_ptr).
  • Keeps ownership transfer into StoragePtr via release() at Slice construction and free-list boundaries.
  • Guards the attribute with __has_attribute(__counted_by__), so default builds are unchanged on compilers without support.

Does not modify Buffer::Slice cursor fields (base_ / data_ / reservable_ / capacity_), ListenerFilterBufferImpl, or the public RawSlice ABI.

AI assistance

This change was authored with AI assistance. I own the design and the diff, understand the ownership/counted_by tradeoff, and will address review feedback.

Testing

  • Existing buffer unit / integration coverage exercises SizedStorage via reserve/commit paths.
  • Attribute is compile-time only and inert without Clang counted_by support.

@repokitteh-read-only

Copy link
Copy Markdown

Hi @LaptopsPlural, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #47442 was opened by LaptopsPlural.

see: more, trace.

SizedStorage is the true alloc-capacity pair (mem_, len_) for Slice
backend storage. Represent mem_ as a raw uint8_t* so Clang's
counted_by can describe the bound, with RAII and release() into
StoragePtr at Slice/free-list boundaries. The attribute is guarded by
__has_attribute and is a no-op on unsupported compilers.

Signed-off-by: Jeff Bindel <jeff@incrediblybased.co>
@LaptopsPlural
LaptopsPlural force-pushed the buffer-sizedstorage-counted-by branch from aed17b2 to 1cef9c9 Compare September 14, 2026 14:55
@kyessenov

Copy link
Copy Markdown
Contributor

/assign-from envoyproxy/senior-maintainers

@repokitteh-read-only

Copy link
Copy Markdown

envoyproxy/senior-maintainers assignee is @phlax

🐱

Caused by: a #47442 (comment) was created by @kyessenov.

see: more, trace.

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