Added opt_abort_conf: abort on invalid config options.
This commit is contained in:
parent
57aaa53f2b
commit
b86d271cbf
@ -874,7 +874,25 @@ mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
|
|||||||
<literal>r-</literal>
|
<literal>r-</literal>
|
||||||
</term>
|
</term>
|
||||||
<listitem><para>Abort-on-warning enabled/disabled. If true, most
|
<listitem><para>Abort-on-warning enabled/disabled. If true, most
|
||||||
warnings are fatal. The process will call
|
warnings are fatal. Note that runtime option warnings are not included
|
||||||
|
(see <link
|
||||||
|
linkend="opt.abort_conf"><mallctl>opt.abort_conf</mallctl></link> for
|
||||||
|
that). The process will call
|
||||||
|
<citerefentry><refentrytitle>abort</refentrytitle>
|
||||||
|
<manvolnum>3</manvolnum></citerefentry> in these cases. This option is
|
||||||
|
disabled by default unless <option>--enable-debug</option> is
|
||||||
|
specified during configuration, in which case it is enabled by default.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry id="opt.abort_conf">
|
||||||
|
<term>
|
||||||
|
<mallctl>opt.abort_conf</mallctl>
|
||||||
|
(<type>bool</type>)
|
||||||
|
<literal>r-</literal>
|
||||||
|
</term>
|
||||||
|
<listitem><para>Abort-on-invalid-configuration enabled/disabled. If
|
||||||
|
true, invalid runtime options are fatal. The process will call
|
||||||
<citerefentry><refentrytitle>abort</refentrytitle>
|
<citerefentry><refentrytitle>abort</refentrytitle>
|
||||||
<manvolnum>3</manvolnum></citerefentry> in these cases. This option is
|
<manvolnum>3</manvolnum></citerefentry> in these cases. This option is
|
||||||
disabled by default unless <option>--enable-debug</option> is
|
disabled by default unless <option>--enable-debug</option> is
|
||||||
|
@ -10,6 +10,7 @@ extern bool malloc_slow;
|
|||||||
|
|
||||||
/* Run-time options. */
|
/* Run-time options. */
|
||||||
extern bool opt_abort;
|
extern bool opt_abort;
|
||||||
|
extern bool opt_abort_conf;
|
||||||
extern const char *opt_junk;
|
extern const char *opt_junk;
|
||||||
extern bool opt_junk_alloc;
|
extern bool opt_junk_alloc;
|
||||||
extern bool opt_junk_free;
|
extern bool opt_junk_free;
|
||||||
|
@ -76,6 +76,7 @@ CTL_PROTO(config_stats)
|
|||||||
CTL_PROTO(config_utrace)
|
CTL_PROTO(config_utrace)
|
||||||
CTL_PROTO(config_xmalloc)
|
CTL_PROTO(config_xmalloc)
|
||||||
CTL_PROTO(opt_abort)
|
CTL_PROTO(opt_abort)
|
||||||
|
CTL_PROTO(opt_abort_conf)
|
||||||
CTL_PROTO(opt_retain)
|
CTL_PROTO(opt_retain)
|
||||||
CTL_PROTO(opt_dss)
|
CTL_PROTO(opt_dss)
|
||||||
CTL_PROTO(opt_narenas)
|
CTL_PROTO(opt_narenas)
|
||||||
@ -267,6 +268,7 @@ static const ctl_named_node_t config_node[] = {
|
|||||||
|
|
||||||
static const ctl_named_node_t opt_node[] = {
|
static const ctl_named_node_t opt_node[] = {
|
||||||
{NAME("abort"), CTL(opt_abort)},
|
{NAME("abort"), CTL(opt_abort)},
|
||||||
|
{NAME("abort_conf"), CTL(opt_abort_conf)},
|
||||||
{NAME("retain"), CTL(opt_retain)},
|
{NAME("retain"), CTL(opt_retain)},
|
||||||
{NAME("dss"), CTL(opt_dss)},
|
{NAME("dss"), CTL(opt_dss)},
|
||||||
{NAME("narenas"), CTL(opt_narenas)},
|
{NAME("narenas"), CTL(opt_narenas)},
|
||||||
@ -1546,6 +1548,7 @@ CTL_RO_CONFIG_GEN(config_xmalloc, bool)
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
CTL_RO_NL_GEN(opt_abort, opt_abort, bool)
|
CTL_RO_NL_GEN(opt_abort, opt_abort, bool)
|
||||||
|
CTL_RO_NL_GEN(opt_abort_conf, opt_abort_conf, bool)
|
||||||
CTL_RO_NL_GEN(opt_retain, opt_retain, bool)
|
CTL_RO_NL_GEN(opt_retain, opt_retain, bool)
|
||||||
CTL_RO_NL_GEN(opt_dss, opt_dss, const char *)
|
CTL_RO_NL_GEN(opt_dss, opt_dss, const char *)
|
||||||
CTL_RO_NL_GEN(opt_narenas, opt_narenas, unsigned)
|
CTL_RO_NL_GEN(opt_narenas, opt_narenas, unsigned)
|
||||||
|
@ -23,6 +23,13 @@ const char *je_malloc_conf
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
bool opt_abort =
|
bool opt_abort =
|
||||||
|
#ifdef JEMALLOC_DEBUG
|
||||||
|
true
|
||||||
|
#else
|
||||||
|
false
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
bool opt_abort_conf =
|
||||||
#ifdef JEMALLOC_DEBUG
|
#ifdef JEMALLOC_DEBUG
|
||||||
true
|
true
|
||||||
#else
|
#else
|
||||||
@ -274,6 +281,9 @@ typedef struct {
|
|||||||
# define UTRACE(a, b, c)
|
# define UTRACE(a, b, c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Whether encountered any invalid config options. */
|
||||||
|
static bool had_conf_error = false;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Function prototypes for static functions that are referenced prior to
|
* 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) {
|
size_t vlen) {
|
||||||
malloc_printf("<jemalloc>: %s: %.*s:%.*s\n", msg, (int)klen, k,
|
malloc_printf("<jemalloc>: %s: %.*s:%.*s\n", msg, (int)klen, k,
|
||||||
(int)vlen, v);
|
(int)vlen, v);
|
||||||
|
had_conf_error = true;
|
||||||
|
if (opt_abort_conf) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1045,6 +1059,10 @@ malloc_conf_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CONF_HANDLE_BOOL(opt_abort, "abort")
|
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")
|
CONF_HANDLE_BOOL(opt_retain, "retain")
|
||||||
if (strncmp("dss", k, klen) == 0) {
|
if (strncmp("dss", k, klen) == 0) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -813,6 +813,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||||||
"Run-time option settings:\n");
|
"Run-time option settings:\n");
|
||||||
}
|
}
|
||||||
OPT_WRITE_BOOL(abort, ",")
|
OPT_WRITE_BOOL(abort, ",")
|
||||||
|
OPT_WRITE_BOOL(abort_conf, ",")
|
||||||
OPT_WRITE_BOOL(retain, ",")
|
OPT_WRITE_BOOL(retain, ",")
|
||||||
OPT_WRITE_CHAR_P(dss, ",")
|
OPT_WRITE_CHAR_P(dss, ",")
|
||||||
OPT_WRITE_UNSIGNED(narenas, ",")
|
OPT_WRITE_UNSIGNED(narenas, ",")
|
||||||
|
Loading…
Reference in New Issue
Block a user