Skip to content

Fix memory tagging, heap profiler, aligned allocation, and interface … - #242

Merged
struct merged 1 commit into
masterfrom
oct_2026_fixes_no_2
Nov 7, 2026
Merged

struct merged 1 commit into
masterfrom
oct_2026_fixes_no_2

Conversation

@struct

@struct struct commented Nov 7, 2026

Copy link
Copy Markdown
Owner

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.

…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 <noreply@anthropic.com>
@struct
struct merged commit eec439f into master Nov 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant