From 67b00824432ed52b1dbbfb071a4708318f2257d8 Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Thu, 19 Dec 2024 17:44:29 -0600 Subject: [PATCH] rocr: Dynamically allocate IsaMap This is to avoid use after free at the program's end, when statics are destructed. Change-Id: Id6bf26f25a58d13bdf1ee99c852adae8add76569 --- runtime/hsa-runtime/core/runtime/isa.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/isa.cpp b/runtime/hsa-runtime/core/runtime/isa.cpp index 4b50772926..1d1cbd9d59 100755 --- a/runtime/hsa-runtime/core/runtime/isa.cpp +++ b/runtime/hsa-runtime/core/runtime/isa.cpp @@ -250,10 +250,12 @@ const Isa *IsaRegistry::GetIsa(const Isa::Version &version, IsaFeature sramecc, } +// TODO: c++20 use constexpr or consteval const std::unordered_map & IsaRegistry::GetSupportedGenericVersions() { static const - std::unordered_map min_gen_versions = { + std::unordered_map * min_gen_versions = + new std::unordered_map { {prepend_isa_prefix("gfx9-generic"), 1}, {prepend_isa_prefix("gfx9-generic:xnack-"), 1}, {prepend_isa_prefix("gfx9-generic:xnack+"), 1}, @@ -279,7 +281,7 @@ IsaRegistry::GetSupportedGenericVersions() { {prepend_isa_prefix("gfx11-generic"), 1}, {prepend_isa_prefix("gfx12-generic"), 1} }; - return min_gen_versions; + return *min_gen_versions; } const IsaRegistry::IsaMap& IsaRegistry::GetSupportedIsas() {