aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--INSTALL6
-rw-r--r--configure.ac23
-rw-r--r--include/jemalloc/internal/jemalloc_internal.h.in7
-rw-r--r--include/jemalloc/internal/jemalloc_internal_defs.h.in6
-rw-r--r--src/jemalloc.c4
6 files changed, 43 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ef7dbfd..a462d02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -133,8 +133,6 @@ found in the git revision history:
- Remove the "stats.huge.allocated", "stats.huge.nmalloc", and
"stats.huge.ndalloc" mallctls.
- Remove the --enable-mremap option.
- - Remove the --enable-ivsalloc option, and merge its functionality into
- --enable-debug.
- Remove the "stats.chunks.current", "stats.chunks.total", and
"stats.chunks.high" mallctls.
diff --git a/INSTALL b/INSTALL
index 517fe02..cd760ca 100644
--- a/INSTALL
+++ b/INSTALL
@@ -92,6 +92,7 @@ any of the following arguments (not a definitive list) to 'configure':
--enable-debug
Enable assertions and validation code. This incurs a substantial
performance hit, but is very useful during application development.
+ Implies --enable-ivsalloc.
--enable-code-coverage
Enable code coverage support, for use during jemalloc test development.
@@ -110,6 +111,11 @@ any of the following arguments (not a definitive list) to 'configure':
Disable statistics gathering functionality. See the "opt.stats_print"
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-prof
Enable heap profiling and leak detection functionality. See the "opt.prof"
option documentation for usage details. When enabled, there are several
diff --git a/configure.ac b/configure.ac
index 4ac7ac8..be49743 100644
--- a/configure.ac
+++ b/configure.ac
@@ -625,7 +625,8 @@ fi
dnl Do not compile with debugging by default.
AC_ARG_ENABLE([debug],
- [AS_HELP_STRING([--enable-debug], [Build debugging code])],
+ [AS_HELP_STRING([--enable-debug],
+ [Build debugging code (implies --enable-ivsalloc)])],
[if test "x$enable_debug" = "xno" ; then
enable_debug="0"
else
@@ -637,8 +638,28 @@ fi
if test "x$enable_debug" = "x1" ; then
AC_DEFINE([JEMALLOC_DEBUG], [ ])
fi
+if test "x$enable_debug" = "x1" ; then
+ AC_DEFINE([JEMALLOC_DEBUG], [ ])
+ enable_ivsalloc="1"
+fi
AC_SUBST([enable_debug])
+dnl Do not validate pointers by default.
+AC_ARG_ENABLE([ivsalloc],
+ [AS_HELP_STRING([--enable-ivsalloc],
+ [Validate pointers passed through the public API])],
+[if test "x$enable_ivsalloc" = "xno" ; then
+ enable_ivsalloc="0"
+else
+ enable_ivsalloc="1"
+fi
+],
+[enable_ivsalloc="0"]
+)
+if test "x$enable_ivsalloc" = "x1" ; then
+ AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
+fi
+
dnl Only optimize if not debugging.
if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index 8ed69ce..b398f31 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -119,6 +119,13 @@ static const bool config_xmalloc =
false
#endif
;
+static const bool config_ivsalloc =
+#ifdef JEMALLOC_IVSALLOC
+ true
+#else
+ false
+#endif
+ ;
#ifdef JEMALLOC_C11ATOMICS
#include <stdatomic.h>
diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in
index 191abc5..a943d23 100644
--- a/include/jemalloc/internal/jemalloc_internal_defs.h.in
+++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in
@@ -187,6 +187,12 @@
#undef JEMALLOC_INTERNAL_FFS
/*
+ * JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
+ * within jemalloc-owned chunks before dereferencing them.
+ */
+#undef JEMALLOC_IVSALLOC
+
+/*
* Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
*/
#undef JEMALLOC_ZONE
diff --git a/src/jemalloc.c b/src/jemalloc.c
index d511009..7e9f486 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -2306,7 +2306,7 @@ je_sallocx(const void *ptr, int flags)
assert(malloc_initialized() || IS_INITIALIZER);
malloc_thread_init();
- if (config_debug)
+ if (config_ivsalloc)
usize = ivsalloc(ptr, config_prof);
else
usize = isalloc(ptr, config_prof);
@@ -2434,7 +2434,7 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr)
assert(malloc_initialized() || IS_INITIALIZER);
malloc_thread_init();
- if (config_debug)
+ if (config_ivsalloc)
ret = ivsalloc(ptr, config_prof);
else
ret = (ptr == NULL) ? 0 : isalloc(ptr, config_prof);