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.
While testing out @tact1m4n3 's wifi work in #861, I got suspicious that we were relying on an allocator that hadn't actually been properly vetted. I used Claude to write a bunch of tests.
These test cases passed!
I then noticed that we could initialize the heap with a size too small for the metadata. I changed
initto return an error (API change).Finally, with Claude I looked at how
dbg_integrity_checkworks, and noticed some issues. Fixing that pointed to extra bugs which we fixed:Chunkconstants calculation@offsetOf(Chunk, "prior_free")to account for padding and to not hardcode types.@sizeOf(Chunk)so also account for potential padding, plus to not hardcode e.g. how many pointers a chunk contains.@alignOf(Chunk)instead of@alignOf(Alloc), this was just straight up incorrect, but the alignment was probably the same.do_allocanddo_resize:our_new_size >= Chunk.min_sizebefore trimming