Skip to content

Commit

Permalink
Temporarily zero out heap memory when destorying a chunk
Browse files Browse the repository at this point in the history
this is needed to reliably trigger heap finaliser bug and can be
reverted after the bug is fixed.
  • Loading branch information
dipinhora committed Oct 7, 2024
1 parent 59ba306 commit 1d33f83
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libponyrt/mem/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ static void destroy_small(small_chunk_t* chunk, uint32_t mark)

char* m = get_m((chunk_t*)chunk);
ponyint_pagemap_set(m, NULL, NULL);
#ifndef PONY_NDEBUG
memset(m, 0, sizeof(block_t));
#endif
POOL_FREE(block_t, m);
POOL_FREE(small_chunk_t, chunk);
}
Expand All @@ -340,7 +343,12 @@ static void destroy_large(large_chunk_t* chunk, uint32_t mark)
large_pagemap(m, chunk->size, NULL, NULL);

if(m != NULL)
{
#ifndef PONY_NDEBUG
memset(m, 0, chunk->size);
#endif
ponyint_pool_free_size(chunk->size, m);
}

POOL_FREE(large_chunk_t, chunk);
}
Expand Down

0 comments on commit 1d33f83

Please sign in to comment.