MOD-10248 - Less restrictive Rust allocator shim#6367
Merged
Conversation
LukeMathWalker
previously approved these changes
Jun 24, 2025
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6367 +/- ##
==========================================
+ Coverage 88.77% 88.88% +0.11%
==========================================
Files 250 250
Lines 41497 41533 +36
Branches 3632 3668 +36
==========================================
+ Hits 36837 36916 +79
+ Misses 4611 4568 -43
Partials 49 49
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
LukeMathWalker
approved these changes
Jun 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
We use the allocator shims to ensure that we have the same allocators when running benchmarks that compare the Rust and C implementations. This will also be used in Rust Unit tests, which link to C Code.
Why do we need this
The
mempool_tC-code uses zero as an argument for' malloc', e.g., This PR fixes crashes thatmempool_tis called from in Rust benchmarks or unit tests.It is an extraction of: #6342
Describe the changes
Before this PR we panicked if the allocation functions in Rust were called with a zero size. However, that is too restrictive: The C standard permits this and leaves it open to the implementer to decide whether to return a nullptr or an actual address. The standard only states that the a pointer returned by
malloccalled with size zero must never be dereferenced.We return a nullptr if
sizeorcountis a zero argument from now on.C-Standard
Mark if applicable