diff options
author | Jason Evans <jasone@canonware.com> | 2017-04-21 18:00:36 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2017-04-21 21:34:35 (GMT) |
commit | 3823effe126ec602c438b02eb70d4c258a2f0e3f (patch) | |
tree | 11d3627895df246d4553ab733fd3a3f2050fa900 /src | |
parent | b2a8453a3fa653dc71f82ac9df64b012917f6b8c (diff) | |
download | jemalloc-3823effe126ec602c438b02eb70d4c258a2f0e3f.zip jemalloc-3823effe126ec602c438b02eb70d4c258a2f0e3f.tar.gz jemalloc-3823effe126ec602c438b02eb70d4c258a2f0e3f.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/jemalloc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index e08226c..27a9fd7 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -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); |