Skip to content

Commit ae22347

Browse files
committed
removed call to ZeModuleDestroy
Signed-off-by: Byoungro So <byoungro.so@intel.com>
1 parent c3157ce commit ae22347

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,12 +4300,12 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
43004300
ZE_CALL_NOCHECK(zeModuleCreate, (ZeContext, ZeDevice, &ZeModuleDesc,
43014301
&ZeModule, &Program->ZeBuildLog));
43024302
if (ZeResult != ZE_RESULT_SUCCESS) {
4303-
// We need to clear Program state to avoid double destroy of zeModule in
4304-
// case where SYCL RT calls piProgramRelease().
4305-
// We should not return with an error code here due to the comments below.
4303+
// We adjust pi_program below to avoid attempting to release zeModule when
4304+
// RT calls piProgramRelease().
43064305
Program->ZeModule = nullptr;
43074306
Program->Code.reset();
43084307
Program->State = _pi_program::Invalid;
4308+
return mapError(ZeResult);
43094309
}
43104310
// The call to zeModuleCreate does not report an error if there are
43114311
// unresolved symbols because it thinks these could be resolved later via a
@@ -4314,9 +4314,9 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
43144314
// check now for unresolved symbols.
43154315
ZeResult = checkUnresolvedSymbols(ZeModule, &Program->ZeBuildLog);
43164316
if (ZeResult != ZE_RESULT_SUCCESS) {
4317-
// remove ZeModule that is associated with the failed program
4318-
ZE_CALL(zeModuleDestroy, (ZeModule));
4319-
4317+
// Note that the ZeModule is still allocated and will be released when
4318+
// the user catch the exception that RT throws.
4319+
// Otherwise, the user program crashes and memory leak is not a concern.
43204320
if (ZeResult == ZE_RESULT_ERROR_MODULE_LINK_FAILURE)
43214321
return PI_BUILD_PROGRAM_FAILURE;
43224322
return mapError(ZeResult);

0 commit comments

Comments
 (0)