refactor(allocator): improve safety of dealloc_chunk_list#21779
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 26, 2026
Merged
Conversation
This was referenced Apr 26, 2026
Merged
Member
Author
This was referenced Apr 26, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
67ff1f2 to
a82c143
Compare
8f6d4d9 to
a44ec68
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Arena’s chunk deallocation helper to make aliasing/lifetime boundaries around ChunkFooter references explicit, reduce the scope of unsafe blocks, and document the safety assumptions involved in freeing arena chunks.
Changes:
- Refactors
dealloc_chunk_listto ensure&ChunkFooterborrows are not live acrossdealloc. - Narrows
unsafeblocks to only the operations that require them. - Adds safety documentation/comments explaining required invariants.
a82c143 to
1d77796
Compare
a44ec68 to
e689974
Compare
This was referenced Apr 26, 2026
e689974 to
75bb873
Compare
Contributor
Merge activity
|
Improve the safety of `Arena`'s `dealloc_chunk_list` function:
- Ensure `&ChunkFooter` reference is not live when the chunk containing that `ChunkFooter` is deallocated.
- Scope `unsafe { ... }` blocks to cover just the statements that require them.
- Document the safety invariants.
I don't believe there was a soundness issue here (as `&ChunkFooter` references were short-lived), but this change makes the importance of avoiding live references clear, and explicitly guards against it.
1d77796 to
6889c46
Compare
75bb873 to
5e7dbac
Compare
Base automatically changed from
om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators
to
main
April 26, 2026 22:09
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.

Improve the safety of
Arena'sdealloc_chunk_listfunction:&ChunkFooterreference is not live when the chunk containing thatChunkFooteris deallocated.unsafe { ... }blocks to cover just the statements that require them.I don't believe there was a soundness issue here (as
&ChunkFooterreferences were short-lived), but this change makes the importance of avoiding live references clear, and explicitly guards against it.