mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Decrement context ref count as a last action in program destructor.
- There are various calls to device inside destructor. - Memory manager is protected via device , which is protected by context. - If context is destroyed it means that device may be destroyed, which means that memory manager may be destroyed and we have a seg fault. Change-Id: I2cb6a69790f53bf2c9fba89160078b009e105574
This commit is contained in:
@ -2941,3 +2941,19 @@ TEST(SimpleProgramTests, givenDefaultProgramWhenSetDeviceIsCalledThenDeviceIsSet
|
||||
pProgram.SetDevice(nullptr);
|
||||
EXPECT_EQ(nullptr, pProgram.getDevicePtr());
|
||||
}
|
||||
|
||||
TEST(ProgramDestructionTests, givenProgramUsingDeviceWhenItIsDestroyedAfterPlatfromCleanupThenItIsCleanedUpProperly) {
|
||||
constructPlatform();
|
||||
platformImpl->initialize();
|
||||
auto device = platformImpl->getDevice(0);
|
||||
MockContext *context = new MockContext(device, false);
|
||||
MockProgram *pProgram = new MockProgram(context, false);
|
||||
auto globalAllocation = device->getMemoryManager()->allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
pProgram->setGlobalSurface(globalAllocation);
|
||||
|
||||
platformImpl.reset(nullptr);
|
||||
EXPECT_EQ(1, device->getRefInternalCount());
|
||||
EXPECT_EQ(1, pProgram->getRefInternalCount());
|
||||
context->decRefInternal();
|
||||
pProgram->decRefInternal();
|
||||
}
|
||||
|
Reference in New Issue
Block a user