Skip to content

Commit 2551b19

Browse files
[SYCL] Fix command dependency handling when adding a command group (#1437)
Fixes an issue where a dependency vector that was iterated over could have its iterators invalidated inside of the loop. Signed-off-by: Sergey Semenov <[email protected]>
1 parent 0c3e012 commit 2551b19

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,10 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr<detail::CG> CommandGroup,
686686
}
687687

688688
// Set new command as user for dependencies and update leaves.
689-
for (DepDesc &Dep : NewCmd->MDeps) {
689+
// Node dependencies can be modified further when adding the node to leaves,
690+
// iterate over their copy.
691+
std::vector<DepDesc> Deps = NewCmd->MDeps;
692+
for (DepDesc &Dep : Deps) {
690693
Dep.MDepCommand->addUser(NewCmd.get());
691694
const Requirement *Req = Dep.MDepRequirement;
692695
MemObjRecord *Record = getMemObjRecord(Req->MSYCLMemObj);

0 commit comments

Comments
 (0)