Add assertions.
Check for interior pointers in arena_[ds]alloc(). Check for corrupt pointers in tcache_alloc().
This commit is contained in:
parent
6b5974403b
commit
f00bb7f132
@ -495,6 +495,9 @@ arena_dalloc(arena_t *arena, arena_chunk_t *chunk, void *ptr)
|
|||||||
CHUNK_MAP_PG_MASK) >> CHUNK_MAP_PG_SHIFT)) <<
|
CHUNK_MAP_PG_MASK) >> CHUNK_MAP_PG_SHIFT)) <<
|
||||||
PAGE_SHIFT));
|
PAGE_SHIFT));
|
||||||
assert(run->magic == ARENA_RUN_MAGIC);
|
assert(run->magic == ARENA_RUN_MAGIC);
|
||||||
|
assert(((uintptr_t)ptr - ((uintptr_t)run +
|
||||||
|
(uintptr_t)run->bin->reg0_offset)) %
|
||||||
|
run->bin->reg_size == 0);
|
||||||
bin = run->bin;
|
bin = run->bin;
|
||||||
malloc_mutex_lock(&bin->lock);
|
malloc_mutex_lock(&bin->lock);
|
||||||
arena_dalloc_bin(arena, chunk, ptr, mapelm);
|
arena_dalloc_bin(arena, chunk, ptr, mapelm);
|
||||||
@ -502,8 +505,10 @@ arena_dalloc(arena_t *arena, arena_chunk_t *chunk, void *ptr)
|
|||||||
#ifdef JEMALLOC_TCACHE
|
#ifdef JEMALLOC_TCACHE
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else {
|
||||||
|
assert(((uintptr_t)ptr & PAGE_MASK) == 0);
|
||||||
arena_dalloc_large(arena, chunk, ptr);
|
arena_dalloc_large(arena, chunk, ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ tcache_alloc(tcache_t *tcache, size_t size, bool zero)
|
|||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
assert(arena_salloc(ret) == tcache->arena->bins[binind].reg_size);
|
||||||
|
|
||||||
if (zero == false) {
|
if (zero == false) {
|
||||||
#ifdef JEMALLOC_FILL
|
#ifdef JEMALLOC_FILL
|
||||||
|
@ -1492,8 +1492,12 @@ arena_salloc(const void *ptr)
|
|||||||
(uintptr_t)((pageind - ((mapbits & CHUNK_MAP_PG_MASK) >>
|
(uintptr_t)((pageind - ((mapbits & CHUNK_MAP_PG_MASK) >>
|
||||||
CHUNK_MAP_PG_SHIFT)) << PAGE_SHIFT));
|
CHUNK_MAP_PG_SHIFT)) << PAGE_SHIFT));
|
||||||
assert(run->magic == ARENA_RUN_MAGIC);
|
assert(run->magic == ARENA_RUN_MAGIC);
|
||||||
|
assert(((uintptr_t)ptr - ((uintptr_t)run +
|
||||||
|
(uintptr_t)run->bin->reg0_offset)) % run->bin->reg_size ==
|
||||||
|
0);
|
||||||
ret = run->bin->reg_size;
|
ret = run->bin->reg_size;
|
||||||
} else {
|
} else {
|
||||||
|
assert(((uintptr_t)ptr & PAGE_MASK) == 0);
|
||||||
ret = mapbits & ~PAGE_MASK;
|
ret = mapbits & ~PAGE_MASK;
|
||||||
assert(ret != 0);
|
assert(ret != 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user