Skip to content

Commit 4074fd7

Browse files
smilczekigcbot
authored andcommitted
Don't use pKernelModule after potential delete.
pKernelModule holds a pointer to llvm::Module. This pointer is passed to oclContext. However, if a ShaderOverride happens, oclContext can call delete on the module, leaving pKernelModule a dangling pointer. This causes issues if pKernelModule is dereferenced.
1 parent baa8240 commit 4074fd7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

IGC/AdaptorOCL/dllInterfaceCompute.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO
11801180
}
11811181

11821182
oclContext.hash = inputShHash;
1183+
// FIXME: pKernelModule can become a dangling pointer in case of ShaderOverride.
11831184
oclContext.setModule(pKernelModule);
11841185
if (oclContext.isSPIRV()) {
11851186
deserialize(*oclContext.getModuleMetaData(), pKernelModule);
@@ -1369,7 +1370,7 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs, STB_TranslateO
13691370
auto metricData = "n\a";
13701371
size_t metricDataSize = sizeof(metricData);
13711372

1372-
unsigned PtrSzInBits = pKernelModule->getDataLayout().getPointerSizeInBits();
1373+
unsigned PtrSzInBits = oclContext.getModule()->getDataLayout().getPointerSizeInBits();
13731374
unsigned int pointerSizeInBytes = (PtrSzInBits == 64) ? 8 : 4;
13741375
oclContext.m_programOutput.GetZEBinary(llvm_os, pointerSizeInBytes, spv_data, spv_size, metricData, metricDataSize,
13751376
pInputArgs->pOptions, pInputArgs->OptionsSize);

0 commit comments

Comments
 (0)