From a81f754b1b01fe57ee4aa50650e2cefb4a4fb897 Mon Sep 17 00:00:00 2001 From: Morakito Date: Thu, 17 Apr 2025 17:24:36 +0800 Subject: [PATCH] Optimize: mark the padding bytes no access mark the padding bytes and mi_padding_t struct no access for all kinds of pages to improve asan accuracy(issue #1043) --- src/page.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/page.c b/src/page.c index 6a693e89..b02bb359 100644 --- a/src/page.c +++ b/src/page.c @@ -1016,6 +1016,16 @@ void* _mi_malloc_generic(mi_heap_t* heap, size_t size, bool zero, size_t huge_al p = _mi_page_malloc_zero(heap, page, size, zero); mi_assert_internal(p != NULL); } + +#if MI_PADDING + mi_padding_t* const padding = (mi_padding_t*)((uint8_t*)p + mi_page_usable_block_size(page)); + size_t delta = padding->delta; + + uint8_t* fill = (uint8_t*)padding - delta; + const size_t maxpad = (delta > MI_MAX_ALIGN_SIZE ? MI_MAX_ALIGN_SIZE : delta); + mi_track_mem_noaccess(fill, maxpad + MI_PADDING_SIZE); +#endif + // move singleton pages to the full queue if (page->reserved == page->used) { mi_page_to_full(page, mi_page_queue_of(page));