From cece649de57dbd5dc7052d6e45ca3bd47fd0913b Mon Sep 17 00:00:00 2001 From: Sergey Semenov <43845535+sergey-semenov@users.noreply.github.com> Date: Tue, 17 Nov 2020 21:33:53 +0300 Subject: [PATCH] [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. --- .../scheduler/CommandsWaitForEvents.cpp | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/sycl/unittests/scheduler/CommandsWaitForEvents.cpp b/sycl/unittests/scheduler/CommandsWaitForEvents.cpp index 51c9c0abc0611..420a536531c0a 100644 --- a/sycl/unittests/scheduler/CommandsWaitForEvents.cpp +++ b/sycl/unittests/scheduler/CommandsWaitForEvents.cpp @@ -71,21 +71,18 @@ TEST_F(SchedulerTest, CommandsWaitForEvents) { return; } - queue Q1; - queue Q2; - - unittest::PiMock Mock1(Q1); - unittest::PiMock Mock2(Q2); - - Mock1.redefine(waitFunc); - Mock1.redefine(retainReleaseFunc); - Mock1.redefine(retainReleaseFunc); - Mock1.redefine(getEventInfoFunc); - - Mock2.redefine(waitFunc); - Mock2.redefine(retainReleaseFunc); - Mock2.redefine(retainReleaseFunc); - Mock2.redefine(getEventInfoFunc); + platform Plt{Selector}; + unittest::PiMock Mock{Plt}; + + Mock.redefine(waitFunc); + Mock.redefine(retainReleaseFunc); + Mock.redefine(retainReleaseFunc); + Mock.redefine(getEventInfoFunc); + + context Ctx1{Plt}; + queue Q1{Ctx1, Selector}; + context Ctx2{Plt}; + queue Q2{Ctx2, Selector}; TestContext.reset(new TestCtx(Q1, Q2));