diff --git a/INSTALL b/INSTALL index e4f7bbd5..00c428b1 100644 --- a/INSTALL +++ b/INSTALL @@ -124,9 +124,10 @@ any of the following arguments (not a definitive list) to 'configure': option documentation for usage details. --enable-ivsalloc - Enable validation code, which verifies that pointers reside within - jemalloc-owned chunks before dereferencing them. This incurs a minor - performance hit. + Enable validation code for malloc_usable_size() and sallocx(), which + verifies that pointers reside within jemalloc-owned extents before + dereferencing metadata. This incurs a minor performance hit, and causes + the functions to return 0 for failed lookups. --enable-prof Enable heap profiling and leak detection functionality. See the "opt.prof" diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in index fb3991bc..243aae6c 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -1061,12 +1061,19 @@ ivsalloc(tsdn_t *tsdn, const void *ptr) { extent_t *extent; - /* Return 0 if ptr is not within a chunk managed by jemalloc. */ + /* + * Return 0 if ptr is not within an extent managed by jemalloc. This + * function has two extra costs relative to isalloc(): + * - The extent_lookup() call cannot claim to be a dependent lookup, + * which induces rtree lookup load dependencies. + * - The lookup may fail, so there is an extra branch to check for + * failure. + * */ extent = extent_lookup(tsdn, ptr, false); if (extent == NULL) return (0); assert(extent_active_get(extent)); - /* Only arena chunks should be looked up via interior pointers. */ + /* Only slab members should be looked up via interior pointers. */ assert(extent_addr_get(extent) == ptr || extent_slab_get(extent)); return (isalloc(tsdn, extent, ptr)); diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in index 7a38c91d..6721bc85 100644 --- a/include/jemalloc/internal/jemalloc_internal_defs.h.in +++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in @@ -195,7 +195,7 @@ /* * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside - * within jemalloc-owned chunks before dereferencing them. + * within jemalloc-owned extents before dereferencing them. */ #undef JEMALLOC_IVSALLOC