fix(ocl) fixing race condition in createFclTranslationCtx

In rare case of multiple threads trying to set fclBaseTranslationCtx,
there was a potential for use after free (double delete) on
std::unique_ptr::reset.

Resolves: NEO-7767

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor
2023-03-03 11:24:48 +00:00
committed by Compute-Runtime-Automation
parent 5b2e1f619c
commit f7cf09d195
3 changed files with 18 additions and 7 deletions

View File

@@ -473,7 +473,10 @@ CIF::RAII::UPtr_t<IGC::FclOclTranslationCtxTagOCL> CompilerInterface::createFclT
}
if (fclBaseTranslationCtx == nullptr) {
fclBaseTranslationCtx = deviceCtx->CreateTranslationCtx(inType, outType);
auto ulock = this->lock();
if (fclBaseTranslationCtx == nullptr) {
fclBaseTranslationCtx = deviceCtx->CreateTranslationCtx(inType, outType);
}
}
return deviceCtx->CreateTranslationCtx(inType, outType);