mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-04 22:49:32 +03:00
fix asan tracking by explicitly setting memory to undefined before a free
This commit is contained in:
parent
3f69119936
commit
76b0873ce2
3 changed files with 7 additions and 7 deletions
|
@ -627,6 +627,9 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi
|
||||||
if (size==0) return;
|
if (size==0) return;
|
||||||
const bool all_committed = (committed_size == size);
|
const bool all_committed = (committed_size == size);
|
||||||
|
|
||||||
|
// need to set all memory to undefined as some parts may still be marked as no_access (like padding etc.)
|
||||||
|
mi_track_mem_undefined(p,size);
|
||||||
|
|
||||||
if (mi_memkind_is_os(memid.memkind)) {
|
if (mi_memkind_is_os(memid.memkind)) {
|
||||||
// was a direct OS allocation, pass through
|
// was a direct OS allocation, pass through
|
||||||
if (!all_committed && committed_size > 0) {
|
if (!all_committed && committed_size > 0) {
|
||||||
|
@ -656,9 +659,6 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to set all memory to undefined as some parts may still be marked as no_access (like padding etc.)
|
|
||||||
mi_track_mem_undefined(p,size);
|
|
||||||
|
|
||||||
// potentially decommit
|
// potentially decommit
|
||||||
if (arena->memid.is_pinned || arena->blocks_committed == NULL) {
|
if (arena->memid.is_pinned || arena->blocks_committed == NULL) {
|
||||||
mi_assert_internal(all_committed);
|
mi_assert_internal(all_committed);
|
||||||
|
|
Loading…
Add table
Reference in a new issue