Remove --enable-ivsalloc.

Continue to use ivsalloc() when --enable-debug is specified (and add
assertions to guard against 0 size), but stop providing a documented
explicit semantics-changing band-aid to dodge undefined behavior in
sallocx() and malloc_usable_size().  ivsalloc() remains compiled in,
unlike when #211 restored --enable-ivsalloc, and if
JEMALLOC_FORCE_IVSALLOC is defined during compilation, sallocx() and
malloc_usable_size() will still use ivsalloc().

This partially resolves #580.
This commit is contained in:
Jason Evans 2017-04-21 11:00:36 -07:00
parent b2a8453a3f
commit 3823effe12
5 changed files with 23 additions and 42 deletions

View file

@ -2678,12 +2678,14 @@ je_sallocx(const void *ptr, int flags) {
tsdn_t *tsdn;
assert(malloc_initialized() || IS_INITIALIZER);
assert(ptr != NULL);
tsdn = tsdn_fetch();
witness_assert_lockless(tsdn);
if (config_ivsalloc) {
if (config_debug || force_ivsalloc) {
usize = ivsalloc(tsdn, ptr);
assert(force_ivsalloc || usize != 0);
} else {
usize = isalloc(tsdn, ptr);
}
@ -2885,10 +2887,15 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr) {
tsdn = tsdn_fetch();
witness_assert_lockless(tsdn);
if (config_ivsalloc) {
ret = ivsalloc(tsdn, ptr);
if (unlikely(ptr == NULL)) {
ret = 0;
} else {
ret = (ptr == NULL) ? 0 : isalloc(tsdn, ptr);
if (config_debug || force_ivsalloc) {
ret = ivsalloc(tsdn, ptr);
assert(force_ivsalloc || ret != 0);
} else {
ret = isalloc(tsdn, ptr);
}
}
witness_assert_lockless(tsdn);