From f0063ba8da27bb1294b6d6179650fade43fa87b7 Mon Sep 17 00:00:00 2001 From: Aidan Belton-Schure Date: Wed, 25 Sep 2024 13:48:39 +0000 Subject: [PATCH] SWDEV-485827 release hostcall listener memory regardless of thread status The early return if the thread is not alive causes memory leaks. Neither doorbell_ or urilocator are released if the thread is not alive. This change alters the logic so regardless of the thread status the HostcallListener releases its memory. Change-Id: Ie912360ec0e2ee257de9937b1a8d7375e6aebd83 --- rocclr/device/devhostcall.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/rocclr/device/devhostcall.cpp b/rocclr/device/devhostcall.cpp index 4a5bfb235b..3c8233f73e 100644 --- a/rocclr/device/devhostcall.cpp +++ b/rocclr/device/devhostcall.cpp @@ -334,15 +334,14 @@ void HostcallListener::consumePackets() { } void HostcallListener::terminate() { - if (thread_.state() < Thread::FINISHED && !amd::Os::isThreadAlive(thread_)) { - return; - } - kHostThreadActive.state = Init::State::kExit; - doorbell_->Reset(SIGNAL_DONE); + if (thread_.state() >= Thread::FINISHED || amd::Os::isThreadAlive(thread_)) { + kHostThreadActive.state = Init::State::kExit; + doorbell_->Reset(SIGNAL_DONE); - // FIXME_lmoriche: fix termination handshake - while (thread_.state() < Thread::FINISHED) { - amd::Os::yield(); + // FIXME_lmoriche: fix termination handshake + while (thread_.state() < Thread::FINISHED) { + amd::Os::yield(); + } } #if defined(__clang__)