From 523e6e883a5cf97d41f2b256cd16a6da1237c6e8 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Mon, 17 Jan 2022 18:16:48 -0600 Subject: [PATCH] Do not discard fragment allocator blocks multiple times. discardBlock may be called multiple times on the same block. We must not discard the block multiple times or we will corrupt in-use memory accounting. Change-Id: Ife9f3162785965a795dcf81887d4d447cc096e62 [ROCm/ROCR-Runtime commit: b9a0c1d3137075cde50a5115e2fddb3234523806] --- .../rocr-runtime/runtime/hsa-runtime/core/util/simple_heap.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/util/simple_heap.h b/projects/rocr-runtime/runtime/hsa-runtime/core/util/simple_heap.h index 51eb38eb84..ef4c8cb477 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/util/simple_heap.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/util/simple_heap.h @@ -300,6 +300,9 @@ template class SimpleHeap { (frag_map.rbegin()->first + frag_map.rbegin()->second.size <= base)) return false; + // Is block already discarded? + if (frag_map.begin()->second.discard) return true; + // Mark all fragments for discard and compute block size. Removes freelist records for all // fragments in the block. size_t size = 0;