From 4b03017e8abe117986ec913d3d139ddb6fea40a3 Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Wed, 4 Sep 2024 09:35:54 +0100 Subject: [PATCH] SWDEV-478065 - Embed host thread in shared_ptr This shows up in some valgrind runs. Make sure the resources are released. Change-Id: I34c25c00370a221585895655744831215136d5f4 --- rocclr/device/rocm/rocvirtual.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index 7328642bb8..4f0a93348b 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -186,9 +186,11 @@ void Timestamp::checkGpuTime() { bool HsaAmdSignalHandler(hsa_signal_value_t value, void* arg) { Timestamp* ts = reinterpret_cast(arg); - amd::Thread* thread = amd::Thread::current(); - if (!(thread != nullptr || - ((thread = new amd::HostThread()) != nullptr && thread == amd::Thread::current()))) { + static std::shared_ptr thread; + if (amd::Thread::current() == nullptr) { + thread = std::make_shared(); + } + if (thread.get() != amd::Thread::current()) { return false; }