diff --git a/src/os.c b/src/os.c index 1dbcb969..9db16fa1 100644 --- a/src/os.c +++ b/src/os.c @@ -552,6 +552,7 @@ void* _mi_os_remap(void* p, size_t size, size_t newsize, mi_memid_t* memid, mi_s return mi_os_remap_copy(p, size, newsize, alignment, memid, stats); } + mi_track_mem_defined(newp, size); newmemid.initially_committed = true; if (p == NULL && extend_is_zero) { newmemid.initially_zero = true; diff --git a/test/main-override-static.c b/test/main-override-static.c index 1427bdf2..fb368309 100644 --- a/test/main-override-static.c +++ b/test/main-override-static.c @@ -20,12 +20,14 @@ static void alloc_huge(void); static void test_heap_walk(void); static void test_remap(bool start_remappable); static void test_remap2(void); +static void test_remap3(void); int main() { mi_version(); mi_stats_reset(); - test_remap2(); + //test_remap2(); + test_remap3(); //test_remap(true); // detect double frees and heap corruption @@ -221,7 +223,7 @@ static void test_heap_walk(void) { mi_heap_visit_blocks(heap, true, &test_visit, NULL); } -static void test_remap2(void) { +static void test_remap2(void) { // By Jason Gibson int* p = (int*)mi_malloc(356); p = (int*)mi_realloc(p, 583); memset(p, '\0', 580); @@ -230,6 +232,21 @@ static void test_remap2(void) { mi_free(p); } +static void test_remap3(void) { // by Jason Gibson + int* x = (int*)mi_malloc(438); + x = (int*)mi_realloc(x, 1500705); + + x = (int*)mi_realloc(x, 3000711); + x = (int*)mi_realloc(x, 6000723); + x = (int*)mi_realloc(x, 10500741); + x = (int*)mi_realloc(x, 16500765); + x = (int*)mi_realloc(x, 25500801); + x = (int*)mi_realloc(x, 39000855); + x = (int*)mi_realloc(x, 60000939); + + mi_free(x); +} + static void test_remap(bool start_remappable) { const size_t iterN = 100; const size_t size0 = 64 * 1024 * 1024;