From 4fb019555b725921ad4f55690f33572c29b7ff29 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 14 Dec 2021 22:27:27 -0500 Subject: [PATCH] Fix for segfault after removing PrefetchRange from map The start iterator becomes invalid after it is removed from std::map prefetch_map_. This was causing a segfault when the iterator is incremented afterwards. Signed-off-by: David Yat Sin Change-Id: I4b0b763d2cb4ee99c0b8571c2c526b834e74077a [ROCm/ROCR-Runtime commit: 86164fbfece6c0925a8c497e821ae93735ac1896] --- .../rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp index 019b739ca9..40ebc35e7f 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -2030,7 +2030,8 @@ hsa_status_t Runtime::SvmPrefetch(void* ptr, size_t size, hsa_agent_t agent, start->second.prev->second.next = start->second.next; if (!isEndNode(start)) start->second.next->second.prev = start->second.prev; } - prefetch_map_.erase(start); + start = prefetch_map_.erase(start); + continue; } } start++;