From 685104cefc0cf774e5c90223b869eedcd5782ffb Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Tue, 5 Jul 2022 13:06:52 -0400 Subject: [PATCH] SWDEV-329789 - Avoid a race condition with the last command Runtime can reset the last command only if it didn't change since the query at the beginning of finish() Change-Id: I629f2d788e9bbaa17ca4e96b1a753f8131e32463 [ROCm/clr commit: 9e74f1c7f8c16bcdce8256a1cadcfb72e5ba5aba] --- projects/clr/rocclr/platform/commandqueue.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/clr/rocclr/platform/commandqueue.cpp b/projects/clr/rocclr/platform/commandqueue.cpp index 58183aed04..c142a21123 100644 --- a/projects/clr/rocclr/platform/commandqueue.cpp +++ b/projects/clr/rocclr/platform/commandqueue.cpp @@ -136,7 +136,8 @@ void HostQueue::finish() { if (IS_HIP) { ScopedLock sl(vdev()->execution()); ScopedLock l(lastCmdLock_); - if (lastEnqueueCommand_ != nullptr) { + // Runtime can clear the last command only if no other submissions occured during finish() + if (command == lastEnqueueCommand_) { lastEnqueueCommand_->release(); lastEnqueueCommand_ = nullptr; }