Repository navigation
Conversation
macOS: interpose malloc, free, calloc, realloc, reallocf, valloc, posix_memalign, aligned_alloc, malloc_size, malloc_good_size, the typed malloc entry points and the libc++ operator new and delete symbols through a __DATA,__interpose table, register an IsoAlloc malloc zone as the default zone, and forward pointers that belong to libSystem back to their zone instead of aborting or losing them. Both: initialize every mutex and the one time state on the lazy init path (libSystem calls malloc before our constructor), add fork handlers that take every lock in prepare, keep big zones mapped at exit unless ISO_DTOR_CLEANUP, hook valloc and pvalloc, fix the nothrow new and delete signatures, guard the free paths against a NULL root, and never abort from the size lookup used by realloc on foreign pointers. Tests: tests/preload with make preload_tests (alias make test_macos) runs six programs under the real preload mechanism of each OS, in CI for the macOS, clang and gcc jobs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes some longstanding issues with using IsoAlloc with
LD_PRELOADorDYLD_INTERPOSE/DYLD_INSERT_LIBRARIESmacOS: interpose malloc, free, calloc, realloc, reallocf, valloc, posix_memalign, aligned_alloc, malloc_size, malloc_good_size, the typed malloc entry points and the libc++ operator new and delete symbols through a __DATA,__interpose table, register an IsoAlloc malloc zone as the default zone, and forward pointers that belong to libSystem back to their zone instead of aborting or losing them.
Both: initialize every mutex and the one time state on the lazy init path (libSystem calls malloc before our constructor), add fork handlers that take every lock in prepare, keep big zones mapped at exit unless ISO_DTOR_CLEANUP, hook valloc and pvalloc, fix the nothrow new and delete signatures, guard the free paths against a NULL root, and never abort from the size lookup used by realloc on foreign pointers.
Tests: tests/preload with make preload_tests (alias make test_macos) runs six programs under the real preload mechanism of each OS, in CI for the macOS, clang and gcc jobs.