From 5ba7a73f97fe6880dc5328807a1cb9353e77b863 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Fri, 27 Feb 2026 11:45:06 +0100 Subject: Implement free and add testing notes to README free now locates the chunk matching the pointer, marks it as free for TINY/SMALL zones, and munmaps LARGE allocations. Document why ASan is incompatible and list alternatives. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index ef21ed7..971bdf5 100644 --- a/README.md +++ b/README.md @@ -53,3 +53,19 @@ are allocated on demand when the current one is full. LARGE allocations each get their own `mmap` region and are released individually via `munmap`. All returned pointers are 16-byte aligned. + +## Testing + +AddressSanitizer (ASan) cannot be used to test this allocator. ASan intercepts +`malloc`/`free` itself and expects specific allocator metadata (redzones, +quarantine zones) that a custom allocator does not provide. The two +implementations would conflict. Since allocations go through `mmap`, they also +bypass ASan's shadow memory tracking entirely. + +Alternatives for catching bugs: +- **Valgrind** — operates at the binary level without replacing `malloc`, so it + can detect issues in the allocator's own internal logic. +- **Custom tests** — targeted checks for write-after-free, double free, boundary + writes, and stress scenarios. +- **`show_alloc_mem()`** — inspect zone and chunk state visually after + operations. -- cgit v1.2.3