merge from dev

This commit is contained in:
daan 2020-04-28 16:22:38 -07:00
commit 1b0de9b4cf
48 changed files with 384 additions and 934 deletions

View file

@ -184,7 +184,7 @@ int main() {
// double_free1();
// double_free2();
// corrupt_free();
// block_overflow1();
block_overflow1();
void* p1 = malloc(78);
void* p2 = malloc(24);

View file

@ -20,16 +20,18 @@ static void msleep(unsigned long msecs) { Sleep(msecs); }
static void msleep(unsigned long msecs) { usleep(msecs * 1000UL); }
#endif
void heap_no_delete();
void heap_late_free();
void padding_shrink();
void heap_thread_free_large(); // issue #221
void heap_no_delete(); // issue #202
void heap_late_free(); // issue #204
void padding_shrink(); // issue #209
void various_tests();
int main() {
mi_stats_reset(); // ignore earlier allocations
// heap_no_delete(); // issue #202
// heap_late_free(); // issue #204
padding_shrink(); // issue #209
heap_thread_free_large();
heap_no_delete();
heap_late_free();
padding_shrink();
various_tests();
mi_stats_print(NULL);
return 0;
@ -157,3 +159,17 @@ void padding_shrink(void)
t1.join();
mi_free(shared_p);
}
// Issue #221
void heap_thread_free_large_worker() {
mi_free(shared_p);
}
void heap_thread_free_large() {
for (int i = 0; i < 100; i++) {
shared_p = mi_malloc_aligned(2*1024*1024 + 1, 8);
auto t1 = std::thread(heap_thread_free_large_worker);
t1.join();
}
}

View file

@ -152,6 +152,9 @@ int main() {
}
result = ok;
});
CHECK_BODY("malloc-aligned5", {
void* p = mi_malloc_aligned(4097,4096); size_t usable = mi_usable_size(p); result = usable >= 4097 && usable < 10000; mi_free(p);
});
CHECK_BODY("malloc-aligned-at1", {
void* p = mi_malloc_aligned_at(48,32,0); result = (p != NULL && ((uintptr_t)(p) + 0) % 32 == 0); mi_free(p);
});