Safety checks: Indirect through a function.
This will let us share code on failure pathways.pathways
This commit is contained in:
parent
f95a88fcd9
commit
b92c9a1a81
@ -117,6 +117,7 @@ C_SRCS := $(srcroot)src/jemalloc.c \
|
|||||||
$(srcroot)src/prng.c \
|
$(srcroot)src/prng.c \
|
||||||
$(srcroot)src/prof.c \
|
$(srcroot)src/prof.c \
|
||||||
$(srcroot)src/rtree.c \
|
$(srcroot)src/rtree.c \
|
||||||
|
$(srcroot)src/safety_check.c \
|
||||||
$(srcroot)src/stats.c \
|
$(srcroot)src/stats.c \
|
||||||
$(srcroot)src/sc.c \
|
$(srcroot)src/sc.c \
|
||||||
$(srcroot)src/sz.c \
|
$(srcroot)src/sz.c \
|
||||||
|
6
include/jemalloc/internal/safety_check.h
Normal file
6
include/jemalloc/internal/safety_check.h
Normal file
@ -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 */
|
11
src/safety_check.c
Normal file
11
src/safety_check.c
Normal file
@ -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();
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "jemalloc/internal/assert.h"
|
#include "jemalloc/internal/assert.h"
|
||||||
#include "jemalloc/internal/mutex.h"
|
#include "jemalloc/internal/mutex.h"
|
||||||
|
#include "jemalloc/internal/safety_check.h"
|
||||||
#include "jemalloc/internal/sc.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;
|
sz_sum -= szind;
|
||||||
}
|
}
|
||||||
if (sz_sum != 0) {
|
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 "
|
"detected, likely caused by sized deallocation bugs by "
|
||||||
"application. Abort.\n");
|
"application. Abort.\n");
|
||||||
abort();
|
abort();
|
||||||
|
Loading…
Reference in New Issue
Block a user