From afc4f79a6948e87b984a8e6cdc465f45ea6c10a0 Mon Sep 17 00:00:00 2001 From: daan Date: Mon, 6 Apr 2020 12:15:12 -0700 Subject: [PATCH] fix for ensuring heap initialization with static linking on windows on huge allocations (issues #221) --- ide/vs2019/mimalloc-override-test.vcxproj | 6 +++--- src/segment.c | 2 +- test/main-override.cpp | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ide/vs2019/mimalloc-override-test.vcxproj b/ide/vs2019/mimalloc-override-test.vcxproj index a2497a19..7a9202f1 100644 --- a/ide/vs2019/mimalloc-override-test.vcxproj +++ b/ide/vs2019/mimalloc-override-test.vcxproj @@ -176,14 +176,14 @@ + + + {abb5eae7-b3e6-432e-b636-333449892ea7} - - - diff --git a/src/segment.c b/src/segment.c index 55410f59..8aa838a2 100644 --- a/src/segment.c +++ b/src/segment.c @@ -1290,7 +1290,7 @@ void _mi_segment_huge_page_free(mi_segment_t* segment, mi_page_t* page, mi_block mi_assert_internal(mi_atomic_read_relaxed(&segment->thread_id)==0); // claim it and free - mi_heap_t* heap = mi_get_default_heap(); + mi_heap_t* heap = mi_heap_get_default(); // issue #221; don't use the internal get_default_heap as we need to ensure the thread is initialized. // paranoia: if this it the last reference, the cas should always succeed if (mi_atomic_cas_strong(&segment->thread_id, heap->thread_id, 0)) { mi_block_set_next(page, block, page->free); diff --git a/test/main-override.cpp b/test/main-override.cpp index 734e4c94..eda32ae4 100644 --- a/test/main-override.cpp +++ b/test/main-override.cpp @@ -29,10 +29,12 @@ void various_tests(); int main() { mi_stats_reset(); // ignore earlier allocations heap_thread_free_large(); + /* heap_no_delete(); heap_late_free(); padding_shrink(); various_tests(); + */ mi_stats_print(NULL); return 0; }