Include the unrecognized malloc conf option in the error message.

Previously the option causing trouble will not be printed, unless the option
key:value pair format is found.
This commit is contained in:
Qi Wang 2023-08-01 14:28:24 -07:00 committed by Qi Wang
parent 62648c88e5
commit 6816b23862

View File

@ -865,6 +865,14 @@ malloc_conf_multi_sizes_next(const char **slab_size_segment_cur,
return false; return false;
} }
static void
malloc_conf_format_error(const char *msg, const char *begin, const char *end) {
size_t len = end - begin + 1;
len = len > BUFERROR_BUF ? BUFERROR_BUF : len;
malloc_printf("<jemalloc>: %s -- %.*s\n", msg, (int)len, begin);
}
static bool static bool
malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p, malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
char const **v_p, size_t *vlen_p) { char const **v_p, size_t *vlen_p) {
@ -898,13 +906,15 @@ malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
break; break;
case '\0': case '\0':
if (opts != *opts_p) { if (opts != *opts_p) {
malloc_write("<jemalloc>: Conf string ends " malloc_conf_format_error(
"with key\n"); "Conf string ends with key",
*opts_p, opts - 1);
had_conf_error = true; had_conf_error = true;
} }
return true; return true;
default: default:
malloc_write("<jemalloc>: Malformed conf string\n"); malloc_conf_format_error(
"Malformed conf string", *opts_p, opts);
had_conf_error = true; had_conf_error = true;
return true; return true;
} }
@ -922,8 +932,9 @@ malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
* comma if one exists. * comma if one exists.
*/ */
if (*opts == '\0') { if (*opts == '\0') {
malloc_write("<jemalloc>: Conf string ends " malloc_conf_format_error(
"with comma\n"); "Conf string ends with comma",
*opts_p, opts - 1);
had_conf_error = true; had_conf_error = true;
} }
*vlen_p = (uintptr_t)opts - 1 - (uintptr_t)*v_p; *vlen_p = (uintptr_t)opts - 1 - (uintptr_t)*v_p;