ensure forced abandoned pages can be accessed after free

This commit is contained in:
daanx 2024-11-25 18:41:57 -08:00
parent 9b7ac9a1a6
commit 7673aa2517
3 changed files with 26 additions and 21 deletions

View file

@ -411,10 +411,8 @@ void _mi_page_force_abandon(mi_page_t* page) {
// ensure this page is no longer in the heap delayed free list
_mi_heap_delayed_free_all(heap);
// TODO: can we still access the page as it may have been
// freed and the memory decommitted?
// A way around this is to explicitly unlink this page from
// the heap delayed free list.
// We can still access the page meta-info even if it is freed as we ensure
// in `mi_segment_force_abandon` that the segment is not freed (yet)
if (page->capacity == 0) return; // it may have been freed now
// and now unlink it from the page queue and abandon (or free)