Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

[WIP] Deny OOM, embrace try_reserve #448

Closed
wants to merge 13 commits into from

Conversation

VictorKoenders
Copy link
Contributor

@VictorKoenders VictorKoenders commented Dec 11, 2021

With Rust 1.57, several try_reserve methods have been stabilized. This PR makes bincode take advantage of this.

A nightly flag can be set to disable all fallible allocations. This is currently blocked on the following features:

And uses the following features, although this could be implemented manually:

Other useful issues:

  • Vec::push_within_capacity to reduce the amount of unsafe code to replace Vec::push tracking issue

@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch from 269d391 to 5d4fae1 Compare December 11, 2021 09:30
@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2021

Codecov Report

❌ Patch coverage is 51.36986% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.05%. Comparing base (e7dff9d) to head (c4e11a1).
⚠️ Report is 36 commits behind head on trunk.

Files with missing lines Patch % Lines
src/features/impl_alloc.rs 53.43% 61 Missing ⚠️
src/error.rs 0.00% 5 Missing ⚠️
src/features/impl_std.rs 50.00% 2 Missing ⚠️
src/features/serde/mod.rs 0.00% 2 Missing ⚠️
src/features/serde/de_borrowed.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk     #448      +/-   ##
==========================================
- Coverage   57.21%   57.05%   -0.16%     
==========================================
  Files          51       51              
  Lines        4410     4427      +17     
==========================================
+ Hits         2523     2526       +3     
- Misses       1887     1901      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch 4 times, most recently from b806672 to f2731c0 Compare December 11, 2021 10:03
@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch from f2731c0 to 8466fff Compare January 8, 2022 14:55
@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch from 8466fff to c1e6e67 Compare February 1, 2022 13:21
@stale
Copy link

stale bot commented Apr 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 2, 2022
@ZoeyR ZoeyR added the not-stale label Apr 4, 2022
@stale stale bot removed the stale label Apr 4, 2022
@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch 9 times, most recently from cef0e15 to fb27373 Compare August 17, 2022 10:51
@VictorKoenders VictorKoenders marked this pull request as ready for review August 18, 2022 18:34
@ghost
Copy link

ghost commented Oct 10, 2022

image
Forgot a closing paren there in the PR description?

@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch 2 times, most recently from eeeefa5 to 9d58ec1 Compare March 30, 2023 13:10
@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch from 9d58ec1 to 1c67710 Compare September 19, 2023 16:04
Added try_reserve to VecWriter, Vec, VecDeque and HashMap
Made the OOM test succeed on the latest nightly
Made the OOM check work on nightly
Disabled stable checks for now
Removed feature that is stable in current nightly
Fixed issue where Box<[T]> would not do the size limit check
Added a drop guard to `impl<T> Decode for Vec<T>` to make sure memory is not leaked when T::Decode panics
Made the implementation of `VecWriter` use less lines of unsfe
Fixed errors while merging
@VictorKoenders VictorKoenders force-pushed the feature/fallible_allocations branch from cea3f8d to 735e175 Compare March 17, 2024 18:19
@ZoeyR ZoeyR closed this Aug 15, 2025
@ZoeyR ZoeyR deleted the feature/fallible_allocations branch August 15, 2025 11:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants