From a97b7df4b9d144ca81633d522e07c74b70654325 Mon Sep 17 00:00:00 2001 From: Sunday Clement Date: Thu, 29 May 2025 14:52:48 -0400 Subject: [PATCH] rocr: Fix Potential Deadlock Because eventDescrp->mutex is a non-recursive lock attempting to acquire the lock with pthread_mutex_lock can cause the system to hang indefinitely if the lock was already previously aquired with the preceeding call to pthread_mutex_trylock. Signed-off-by: Sunday Clement --- runtime/hsa-runtime/core/util/lnx/os_linux.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp index 88e860b890..da82175184 100644 --- a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp +++ b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp @@ -577,7 +577,10 @@ int WaitForOsEvent(EventHandle event, unsigned int milli_seconds) { } int ret_code = 0; - pthread_mutex_lock(&eventDescrp->mutex); + if(milli_seconds != 0) { + pthread_mutex_lock(&eventDescrp->mutex); + } + if (!eventDescrp->state) { if (milli_seconds == 0) { ret_code = 1;