From b5a9a5c36b63ade022f6edd7713684d902b211b3 Mon Sep 17 00:00:00 2001 From: lyndonli Date: Mon, 10 Mar 2025 17:38:46 +0800 Subject: [PATCH] wsl/hsakmt: Improve error handling in allocation This change ensures consistent error handling across build configurations. Signed-off-by: lyndonli Signed-off-by: Flora Cui Reviewed-by: Tianci Yin Part-of: --- util/simple_heap.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/simple_heap.h b/util/simple_heap.h index 1181682fa0..1fb992eb63 100644 --- a/util/simple_heap.h +++ b/util/simple_heap.h @@ -208,8 +208,11 @@ template class SimpleHeap { cache_size_ -= size; } else { // Alloc new block - new block may be larger than default. void* ptr = block_allocator_.alloc(bytes, size); + if (ptr == nullptr) { + fprintf(stderr, "Block allocation failed, Allocator is expected to throw.\n"); + return nullptr; + } base = reinterpret_cast(ptr); - assert(ptr != nullptr && "Block allocation failed, Allocator is expected to throw."); } in_use_size_ += size;