From 1d8997236cb8e09103436491c8aa34548aa2cb24 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 25 Mar 2024 16:28:15 -0700 Subject: [PATCH] add comment on concurrent access in ptr_unalign --- src/free.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/free.c b/src/free.c index 59c20aed..bf5498a4 100644 --- a/src/free.c +++ b/src/free.c @@ -52,6 +52,9 @@ static inline void mi_free_block_local(mi_page_t* page, mi_block_t* block, bool } // Adjust a block that was allocated aligned, to the actual start of the block in the page. +// note: this can be called from `mi_free_generic_mt` where a non-owning thread accesses the +// `page_start` and `block_size` fields; however these are constant and the page won't be +// deallocated (as the block we are freeing keeps it alive) and thus safe to read concurrently. mi_block_t* _mi_page_ptr_unalign(const mi_page_t* page, const void* p) { mi_assert_internal(page!=NULL && p!=NULL);