Skip to content

Commit

Permalink
[SYCL][NFC] Fix write after free in the CommandsWaitForEvents unit te…
Browse files Browse the repository at this point in the history
…st (#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.
  • Loading branch information
sergey-semenov authored Nov 17, 2020
1 parent d2d20d6 commit cece649
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions sycl/unittests/scheduler/CommandsWaitForEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,18 @@ TEST_F(SchedulerTest, CommandsWaitForEvents) {
return;
}

queue Q1;
queue Q2;

unittest::PiMock Mock1(Q1);
unittest::PiMock Mock2(Q2);

Mock1.redefine<detail::PiApiKind::piEventsWait>(waitFunc);
Mock1.redefine<detail::PiApiKind::piEventRetain>(retainReleaseFunc);
Mock1.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
Mock1.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);

Mock2.redefine<detail::PiApiKind::piEventsWait>(waitFunc);
Mock2.redefine<detail::PiApiKind::piEventRetain>(retainReleaseFunc);
Mock2.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
Mock2.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);
platform Plt{Selector};
unittest::PiMock Mock{Plt};

Mock.redefine<detail::PiApiKind::piEventsWait>(waitFunc);
Mock.redefine<detail::PiApiKind::piEventRetain>(retainReleaseFunc);
Mock.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
Mock.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);

context Ctx1{Plt};
queue Q1{Ctx1, Selector};
context Ctx2{Plt};
queue Q2{Ctx2, Selector};

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

Expand Down

0 comments on commit cece649

Please sign in to comment.