From c22140668188288dc1aec1f019dd878b452909d1 Mon Sep 17 00:00:00 2001 From: pghafari Date: Tue, 14 Feb 2023 20:35:46 -0500 Subject: [PATCH] SWDEV-366520 - DLL_PROCESS_DETACH update making sure the current thread is not null before calling ihipDestroyDevice Change-Id: Ib75e3f9ee1c4e0065986e3fed1065907220f4379 --- hipamd/src/hip_runtime.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_runtime.cpp b/hipamd/src/hip_runtime.cpp index 4c877806ac..78eb4acace 100644 --- a/hipamd/src/hip_runtime.cpp +++ b/hipamd/src/hip_runtime.cpp @@ -46,9 +46,14 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { } #endif // DEBUG break; - case DLL_PROCESS_DETACH: + case DLL_PROCESS_DETACH: { + amd::Thread* thread = amd::Thread::current(); + if (!(thread != nullptr || + ((thread = new amd::HostThread()) != nullptr && thread == amd::Thread::current()))) { + return true; + } ihipDestroyDevice(); - break; + } break; case DLL_THREAD_DETACH: { amd::Thread* thread = amd::Thread::current(); delete thread;