Skip to content

Commit a75072c

Browse files
cjatinmangupta
authored andcommitted
SWDEV-438181 - check stream associated with event
...before we dereference it. It might have been deleted. Change-Id: Ief832ee0907658a40ca42b9d78d19658153a05dd
1 parent d62f6a1 commit a75072c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

hipamd/src/hip_stream.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,15 @@ hipError_t hipStreamWaitEvent_common(hipStream_t stream, hipEvent_t event, unsig
519519
}
520520
hip::Stream* waitStream = reinterpret_cast<hip::Stream*>(stream);
521521
hip::Event* e = reinterpret_cast<hip::Event*>(event);
522-
hip::Stream* eventStream = reinterpret_cast<hip::Stream*>(e->GetCaptureStream());
522+
auto eventStreamHandle = reinterpret_cast<hipStream_t>(e->GetCaptureStream());
523+
// the stream associated with the device might have been destroyed
524+
if (!hip::isValid(eventStreamHandle)) {
525+
// Stream associated with the event has been released
526+
// meaning the event has been completed and we can resume the current stream
527+
return hipSuccess;
528+
}
523529

530+
hip::Stream* eventStream = reinterpret_cast<hip::Stream*>(eventStreamHandle);
524531
if (eventStream != nullptr && eventStream->IsEventCaptured(event) == true) {
525532
ClPrint(amd::LOG_INFO, amd::LOG_API,
526533
"[hipGraph] Current capture node StreamWaitEvent on stream : %p, Event %p", stream,

0 commit comments

Comments
 (0)