diff options
author | David Goldblatt <davidgoldblatt@fb.com> | 2019-03-20 20:06:53 (GMT) |
---|---|---|
committer | David Goldblatt <davidtgoldblatt@gmail.com> | 2019-04-15 23:48:12 (GMT) |
commit | b92c9a1a81f3f68da87afe5887d8450fef0700d3 (patch) | |
tree | 12077ecd87c07e9abee2256a3fec1767447e156d | |
parent | f95a88fcd92e8ead1a6c5c8b2ca8c401c6eba162 (diff) | |
download | jemalloc-b92c9a1a81f3f68da87afe5887d8450fef0700d3.zip jemalloc-b92c9a1a81f3f68da87afe5887d8450fef0700d3.tar.gz jemalloc-b92c9a1a81f3f68da87afe5887d8450fef0700d3.tar.bz2 |
Safety checks: Indirect through a function.
This will let us share code on failure pathways.pathways
-rw-r--r-- | Makefile.in | 1 | ||||
-rw-r--r-- | include/jemalloc/internal/safety_check.h | 6 | ||||
-rw-r--r-- | src/safety_check.c | 11 | ||||
-rw-r--r-- | src/tcache.c | 3 |
4 files changed, 20 insertions, 1 deletions
diff --git a/Makefile.in b/Makefile.in index 3a09442..8b4a98f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -117,6 +117,7 @@ C_SRCS := $(srcroot)src/jemalloc.c \ $(srcroot)src/prng.c \ $(srcroot)src/prof.c \ $(srcroot)src/rtree.c \ + $(srcroot)src/safety_check.c \ $(srcroot)src/stats.c \ $(srcroot)src/sc.c \ $(srcroot)src/sz.c \ diff --git a/include/jemalloc/internal/safety_check.h b/include/jemalloc/internal/safety_check.h new file mode 100644 index 0000000..52157d1 --- /dev/null +++ b/include/jemalloc/internal/safety_check.h @@ -0,0 +1,6 @@ +#ifndef JEMALLOC_INTERNAL_SAFETY_CHECK_H +#define JEMALLOC_INTERNAL_SAFETY_CHECK_H + +void safety_check_fail(const char *format, ...); + +#endif /*JEMALLOC_INTERNAL_SAFETY_CHECK_H */ diff --git a/src/safety_check.c b/src/safety_check.c new file mode 100644 index 0000000..cbec190 --- /dev/null +++ b/src/safety_check.c @@ -0,0 +1,11 @@ +#include "jemalloc/internal/jemalloc_preamble.h" +#include "jemalloc/internal/jemalloc_internal_includes.h" + +void safety_check_fail(const char *format, ...) { + va_list ap; + + va_start(ap, format); + malloc_vcprintf(NULL, NULL, format, ap); + va_end(ap); + abort(); +} diff --git a/src/tcache.c b/src/tcache.c index 160b0b7..034c69a 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -4,6 +4,7 @@ #include "jemalloc/internal/assert.h" #include "jemalloc/internal/mutex.h" +#include "jemalloc/internal/safety_check.h" #include "jemalloc/internal/sc.h" /******************************************************************************/ @@ -122,7 +123,7 @@ tbin_extents_lookup_size_check(tsdn_t *tsdn, cache_bin_t *tbin, szind_t binind, sz_sum -= szind; } if (sz_sum != 0) { - malloc_printf("<jemalloc>: size mismatch in thread cache " + safety_check_fail("<jemalloc>: size mismatch in thread cache " "detected, likely caused by sized deallocation bugs by " "application. Abort.\n"); abort(); |