From 0b7929327a4af7e6d249975cc713c5ba900ff504 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Mon, 19 Jul 2021 15:45:51 +0100 Subject: [PATCH] Add errors for failing to initialise the system. --- src/backend/pagemap.h | 5 +++++ src/mem/pool.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/backend/pagemap.h b/src/backend/pagemap.h index 22126c8..4f4ab6e 100644 --- a/src/backend/pagemap.h +++ b/src/backend/pagemap.h @@ -134,6 +134,11 @@ namespace snmalloc auto new_body_untyped = PAL::reserve(request_size); + if (new_body_untyped == nullptr) + { + PAL::error("Failed to initialisation snmalloc."); + } + #ifdef SNMALLOC_CHECK_CLIENT // Begin pagemap at random offset within the additionally allocated space. static_assert(bits::is_pow2(sizeof(T)), "Next line assumes this."); diff --git a/src/mem/pool.h b/src/mem/pool.h index e57dbc5..d718c79 100644 --- a/src/mem/pool.h +++ b/src/mem/pool.h @@ -51,6 +51,12 @@ namespace snmalloc p = ChunkAllocator::alloc_meta_data( h, nullptr, std::forward(args)...); + if (p == nullptr) + { + SharedStateHandle::Backend::Pal::error( + "Failed to initialisation thread local allocator."); + } + FlagLock f(pool.lock); p->list_next = pool.list; pool.list = p;