Repository navigation
Fix memory tagging, heap profiler, aligned allocation, and interface … - #242
Merged
Merged
Conversation
…bugs Memory tagging: fix the tag verification comparison which never matched a valid tag, fix the whole zone tag refresh condition and write through the unmasked user pages pointer, reject one-past-the-end pointers, and use modulo for the chunk offset check since chunk sizes are not always a power of 2. Freed chunks now always receive a tag that differs from the previous one so a stale tagged pointer can never verify. Heap profiler: size the zone profiler map for SMALL_SIZE_MAX inclusive, copy the full trace arrays, compute usage percentages with float math, check dladdr results, and call the free profiler under the root lock. Walk frame pointers directly for backtraces since gcc returns 0 for __builtin_return_address(n > 0) on aarch64. Declare profiler globals extern in the header so the profiler links under -fno-common. Aligned allocation: posix_memalign, memalign, aligned_alloc, and the aligned C++ new operators now honor the requested alignment through _iso_alloc_aligned. Alignments up to a page come from an exact fit zone, larger ones from an over-mapped and trimmed big zone. Hooks validate alignment per POSIX. Throwing operator new retries via the new handler and throws bad_alloc rather than returning NULL. Interfaces: iso_alloc_new_zone returns NULL instead of a masked NULL, iso_zone_chunk_count handles a NULL handle. Sanity: only check the sampled chunk canary when it was written. Tests: add aligned_alloc_test to the test suite, aligned new coverage to the C++ tests, valid_tag_ptr_test and tag_refresh_test to the tagging suite, and a profiler_tests target with profiler_test. Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.
Memory tagging: fix the tag verification comparison which never matched a valid tag, fix the whole zone tag refresh condition and write through the unmasked user pages pointer, reject one-past-the-end pointers, and use modulo for the chunk offset check since chunk sizes are not always a power of 2. Freed chunks now always receive a tag that differs from the previous one so a stale tagged pointer can never verify.
Heap profiler: size the zone profiler map for SMALL_SIZE_MAX inclusive, copy the full trace arrays, compute usage percentages with float math, check dladdr results, and call the free profiler under the root lock. Walk frame pointers directly for backtraces since gcc returns 0 for __builtin_return_address(n > 0) on aarch64. Declare profiler globals extern in the header so the profiler links under -fno-common.
Aligned allocation: posix_memalign, memalign, aligned_alloc, and the aligned C++ new operators now honor the requested alignment through _iso_alloc_aligned. Alignments up to a page come from an exact fit zone, larger ones from an over-mapped and trimmed big zone. Hooks validate alignment per POSIX. Throwing operator new retries via the new handler and throws bad_alloc rather than returning NULL.
Interfaces: iso_alloc_new_zone returns NULL instead of a masked NULL, iso_zone_chunk_count handles a NULL handle.
Sanity: only check the sampled chunk canary when it was written.
Tests: add aligned_alloc_test to the test suite, aligned new coverage to the C++ tests, valid_tag_ptr_test and tag_refresh_test to the tagging suite, and a profiler_tests target with profiler_test.