diff options
author | Qi Wang <interwq@gwu.edu> | 2022-05-06 11:28:25 -0700 |
---|---|---|
committer | Qi Wang <interwq@gwu.edu> | 2022-05-06 11:28:25 -0700 |
commit | 54eaed1d8b56b1aa528be3bdd1877e59c56fa90c (patch) | |
tree | e79620e0c00b1f8b6b698fbe74df6bae7d812ae2 /src/safety_check.c | |
parent | ea6b3e973b477b8061e0076bb257dbd7f3faa756 (diff) | |
parent | 304c919829f9f340669b61fa64867cfe5dba8021 (diff) | |
download | jemalloc-master.tar.gz |
Diffstat (limited to 'src/safety_check.c')
-rw-r--r-- | src/safety_check.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/safety_check.c b/src/safety_check.c index 804155dc..209fdda9 100644 --- a/src/safety_check.c +++ b/src/safety_check.c @@ -1,9 +1,21 @@ #include "jemalloc/internal/jemalloc_preamble.h" #include "jemalloc/internal/jemalloc_internal_includes.h" -static void (*safety_check_abort)(const char *message); +static safety_check_abort_hook_t safety_check_abort; -void safety_check_set_abort(void (*abort_fn)(const char *)) { +void safety_check_fail_sized_dealloc(bool current_dealloc, const void *ptr, + size_t true_size, size_t input_size) { + char *src = current_dealloc ? "the current pointer being freed" : + "in thread cache, possibly from previous deallocations"; + + safety_check_fail("<jemalloc>: size mismatch detected (true size %zu " + "vs input size %zu), likely caused by application sized " + "deallocation bugs (source address: %p, %s). Suggest building with " + "--enable-debug or address sanitizer for debugging. Abort.\n", + true_size, input_size, ptr, src); +} + +void safety_check_set_abort(safety_check_abort_hook_t abort_fn) { safety_check_abort = abort_fn; } |