From 2cfb8bc3c16e90b10b73382c81371ff2a93a8aaa Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Wed, 20 Dec 2023 01:28:00 +0000 Subject: [PATCH] SWDEV-438181 - check stream associated with event ...before we dereference it. It might have been deleted. Change-Id: Ief832ee0907658a40ca42b9d78d19658153a05dd --- hipamd/src/hip_stream.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hipamd/src/hip_stream.cpp b/hipamd/src/hip_stream.cpp index c8ff4bd269..e8e286bfb6 100644 --- a/hipamd/src/hip_stream.cpp +++ b/hipamd/src/hip_stream.cpp @@ -534,8 +534,15 @@ hipError_t hipStreamWaitEvent_common(hipStream_t stream, hipEvent_t event, unsig } hip::Stream* waitStream = reinterpret_cast(stream); hip::Event* e = reinterpret_cast(event); - hip::Stream* eventStream = reinterpret_cast(e->GetCaptureStream()); + auto eventStreamHandle = reinterpret_cast(e->GetCaptureStream()); + // the stream associated with the device might have been destroyed + if (!hip::isValid(eventStreamHandle)) { + // Stream associated with the event has been released + // meaning the event has been completed and we can resume the current stream + return hipSuccess; + } + hip::Stream* eventStream = reinterpret_cast(eventStreamHandle); if (eventStream != nullptr && eventStream->IsEventCaptured(event) == true) { ClPrint(amd::LOG_INFO, amd::LOG_API, "[hipGraph] Current capture node StreamWaitEvent on stream : %p, Event %p", stream,