Added opt_abort_conf: abort on invalid config options.

This commit is contained in:
Qi Wang 2017-05-25 15:30:11 -07:00 committed by Qi Wang
parent 57aaa53f2b
commit b86d271cbf
5 changed files with 56 additions and 15 deletions

View file

@ -23,6 +23,13 @@ const char *je_malloc_conf
#endif
;
bool opt_abort =
#ifdef JEMALLOC_DEBUG
true
#else
false
#endif
;
bool opt_abort_conf =
#ifdef JEMALLOC_DEBUG
true
#else
@ -274,6 +281,9 @@ typedef struct {
# define UTRACE(a, b, c)
#endif
/* Whether encountered any invalid config options. */
static bool had_conf_error = false;
/******************************************************************************/
/*
* Function prototypes for static functions that are referenced prior to
@ -847,6 +857,10 @@ malloc_conf_error(const char *msg, const char *k, size_t klen, const char *v,
size_t vlen) {
malloc_printf("<jemalloc>: %s: %.*s:%.*s\n", msg, (int)klen, k,
(int)vlen, v);
had_conf_error = true;
if (opt_abort_conf) {
abort();
}
}
static void
@ -1045,6 +1059,10 @@ malloc_conf_init(void) {
}
CONF_HANDLE_BOOL(opt_abort, "abort")
CONF_HANDLE_BOOL(opt_abort_conf, "abort_conf")
if (opt_abort_conf && had_conf_error) {
abort();
}
CONF_HANDLE_BOOL(opt_retain, "retain")
if (strncmp("dss", k, klen) == 0) {
int i;