mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
When safety_check_fail, also embed hint msg in the abort function name
because there are cases only logging crash stack traces.
This commit is contained in:
@@ -20,6 +20,20 @@ void safety_check_set_abort(safety_check_abort_hook_t abort_fn) {
|
|||||||
safety_check_abort = abort_fn;
|
safety_check_abort = abort_fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In addition to malloc_write, also embed hint msg in the abort function name
|
||||||
|
* because there are cases only logging crash stack traces.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
safety_check_detected_heap_corruption___run_address_sanitizer_build_to_debug(const char *buf) {
|
||||||
|
if (safety_check_abort == NULL) {
|
||||||
|
malloc_write(buf);
|
||||||
|
abort();
|
||||||
|
} else {
|
||||||
|
safety_check_abort(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void safety_check_fail(const char *format, ...) {
|
void safety_check_fail(const char *format, ...) {
|
||||||
char buf[MALLOC_PRINTF_BUFSIZE];
|
char buf[MALLOC_PRINTF_BUFSIZE];
|
||||||
|
|
||||||
@@ -28,10 +42,5 @@ void safety_check_fail(const char *format, ...) {
|
|||||||
malloc_vsnprintf(buf, MALLOC_PRINTF_BUFSIZE, format, ap);
|
malloc_vsnprintf(buf, MALLOC_PRINTF_BUFSIZE, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (safety_check_abort == NULL) {
|
safety_check_detected_heap_corruption___run_address_sanitizer_build_to_debug(buf);
|
||||||
malloc_write(buf);
|
|
||||||
abort();
|
|
||||||
} else {
|
|
||||||
safety_check_abort(buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user