diff options
author | daan <daan@effp.org> | 2022-10-30 12:23:11 -0700 |
---|---|---|
committer | daan <daan@effp.org> | 2022-10-30 12:23:11 -0700 |
commit | b48040e20aa908b4ed4ec13d6a48b0e29214470f (patch) | |
tree | 3b36b878faba2e88504a0262bdbbaf557b7b54d2 | |
parent | 6e11a054a4f751c17c030167e2ea33124d8083da (diff) |
set pages to noaccess explicitly for valgrind precision
-rw-r--r-- | include/mimalloc-types.h | 2 | ||||
-rw-r--r-- | src/alloc.c | 5 | ||||
-rw-r--r-- | src/page.c | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/include/mimalloc-types.h b/include/mimalloc-types.h index 1455da6..6c7c201 100644 --- a/include/mimalloc-types.h +++ b/include/mimalloc-types.h @@ -66,7 +66,7 @@ terms of the MIT license. A copy of the license can be found in the file // Encoded free lists allow detection of corrupted free lists // and can detect buffer overflows, modify after free, and double `free`s. -#if (MI_SECURE>=3 || MI_DEBUG>=1 || MI_PADDING > 0) && !MI_VALGRIND +#if (MI_SECURE>=3 || MI_DEBUG>=1) #define MI_ENCODE_FREELIST 1 #endif diff --git a/src/alloc.c b/src/alloc.c index c9265b0..a341e0e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -39,10 +39,11 @@ extern inline void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t siz mi_assert_internal(page->free == NULL || _mi_ptr_page(page->free) == page); // allow use of the block internally - // todo: can we optimize this call away for non-zero'd release mode? + // note: when tracking we need to avoid ever touching the MI_PADDING since + // that is tracked by valgrind etc. as non-accessible (through the red-zone, see `mimalloc-track.h`) #if MI_TRACK_ENABLED const size_t track_bsize = mi_page_block_size(page); - mi_assert_internal(track_bsize >= size); + mi_assert_internal(track_bsize >= size && track_bsize >= MI_PADDING_SIZE); mi_track_mem_undefined(block,track_bsize - MI_PADDING_SIZE); #endif @@ -616,7 +616,9 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi // set fields mi_page_set_heap(page, heap); size_t page_size; - _mi_segment_page_start(segment, page, block_size, &page_size, NULL); + const void* page_start = _mi_segment_page_start(segment, page, block_size, &page_size, NULL); + MI_UNUSED(page_start); + mi_track_mem_noaccess(page_start,page_size); page->xblock_size = (block_size < MI_HUGE_BLOCK_SIZE ? (uint32_t)block_size : MI_HUGE_BLOCK_SIZE); mi_assert_internal(page_size / block_size < (1L<<16)); page->reserved = (uint16_t)(page_size / block_size); |