Skip to content

Conversation

@a1phyr
Copy link
Contributor

@a1phyr a1phyr commented Oct 23, 2025

I haven't found any discussion on this, but I think that handling those OOM is desirable.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@marmeladema
Copy link
Contributor

Seems similar to #84612

Cc @kornelski

where
A: Allocator,
{
debug_assert!(vec.capacity() >= pos + buf.len());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
debug_assert!(pos <= vec.len());
debug_assert!(buf.len() <= vec.capacity() - pos);

This adds a debug check, and is not dependent on maximum size of allocations to prevent overflow.

{
// For safety reasons, we don't want this sum to overflow ever.
// If this saturates, the reserve should panic to avoid any unsound writing.
// If this saturates, the reserve should fail to avoid any unsound writing.
Copy link
Member

Choose a reason for hiding this comment

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

This now reads badly. Perhaps:

Suggested change
// If this saturates, the reserve should fail to avoid any unsound writing.
// To avoid unsound writing, if this saturates the reserve should fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants