Skip to content

Commit cece649

Browse files
[SYCL][NFC] Fix write after free in the CommandsWaitForEvents unit test (#2784)
The test used to pass two queues with the same platform to two different PiMock objects. Since it's the platform object that PiMock modifies, the changes made by the first PiMock were overwritten by the second one.
1 parent d2d20d6 commit cece649

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

sycl/unittests/scheduler/CommandsWaitForEvents.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,18 @@ TEST_F(SchedulerTest, CommandsWaitForEvents) {
7171
return;
7272
}
7373

74-
queue Q1;
75-
queue Q2;
76-
77-
unittest::PiMock Mock1(Q1);
78-
unittest::PiMock Mock2(Q2);
79-
80-
Mock1.redefine<detail::PiApiKind::piEventsWait>(waitFunc);
81-
Mock1.redefine<detail::PiApiKind::piEventRetain>(retainReleaseFunc);
82-
Mock1.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
83-
Mock1.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);
84-
85-
Mock2.redefine<detail::PiApiKind::piEventsWait>(waitFunc);
86-
Mock2.redefine<detail::PiApiKind::piEventRetain>(retainReleaseFunc);
87-
Mock2.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
88-
Mock2.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);
74+
platform Plt{Selector};
75+
unittest::PiMock Mock{Plt};
76+
77+
Mock.redefine<detail::PiApiKind::piEventsWait>(waitFunc);
78+
Mock.redefine<detail::PiApiKind::piEventRetain>(retainReleaseFunc);
79+
Mock.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
80+
Mock.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);
81+
82+
context Ctx1{Plt};
83+
queue Q1{Ctx1, Selector};
84+
context Ctx2{Plt};
85+
queue Q2{Ctx2, Selector};
8986

9087
TestContext.reset(new TestCtx(Q1, Q2));
9188

0 commit comments

Comments
 (0)