From 22d7c04cb845fa9a8d8e1f3d9a46dd884c8e2b03 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Thu, 12 May 2022 09:37:03 +0100 Subject: [PATCH] debug_check_empty (#521) Currently a failing debug_check_empty does not provide any information. This change allows it to print the size of the one of the allocations that has not been freed. --- src/snmalloc/mem/corealloc.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/snmalloc/mem/corealloc.h b/src/snmalloc/mem/corealloc.h index 8aae67d4..3b9628b5 100644 --- a/src/snmalloc/mem/corealloc.h +++ b/src/snmalloc/mem/corealloc.h @@ -893,14 +893,17 @@ namespace snmalloc */ bool debug_is_empty_impl(bool* result) { - auto test = [&result](auto& queue) { - queue.filter([&result](auto slab_metadata) { + auto test = [&result](auto& queue, smallsizeclass_t size_class) { + queue.filter([&result, size_class](auto slab_metadata) { if (slab_metadata->needed() != 0) { if (result != nullptr) *result = false; else - error("debug_is_empty: found non-empty allocator"); + report_fatal_error( + "debug_is_empty: found non-empty allocator: size={} ({})", + sizeclass_to_size(size_class), + size_class); } return false; }); @@ -908,9 +911,11 @@ namespace snmalloc bool sent_something = flush(true); + smallsizeclass_t size_class = 0; for (auto& alloc_class : alloc_classes) { - test(alloc_class.available); + test(alloc_class.available, size_class); + size_class++; } // Place the static stub message on the queue.