fix for ensuring heap initialization with static linking on windows on huge allocations (issues #221)

This commit is contained in:
daan 2020-04-06 12:15:12 -07:00
parent 84b9b8878e
commit afc4f79a69
3 changed files with 6 additions and 4 deletions

View File

@ -176,14 +176,14 @@
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\test\main-override.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="mimalloc-override.vcxproj">
<Project>{abb5eae7-b3e6-432e-b636-333449892ea7}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\test\main-override.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -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);

View File

@ -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;
}