@@ -55,6 +55,9 @@ ur_result_t setupContext(ur_context_handle_t Context, uint32_t numDevices,
5555bool isInstrumentedKernel (ur_kernel_handle_t hKernel) {
5656 auto hProgram = GetProgram (hKernel);
5757 auto PI = getAsanInterceptor ()->getProgramInfo (hProgram);
58+ if (PI == nullptr ) {
59+ return false ;
60+ }
5861 return PI->isKernelInstrumented (hKernel);
5962}
6063
@@ -290,8 +293,9 @@ __urdlllocal ur_result_t UR_APICALL urProgramRetain(
290293 UR_CALL (pfnRetain (hProgram));
291294
292295 auto ProgramInfo = getAsanInterceptor ()->getProgramInfo (hProgram);
293- UR_ASSERT (ProgramInfo != nullptr , UR_RESULT_ERROR_INVALID_VALUE);
294- ProgramInfo->RefCount ++;
296+ if (ProgramInfo != nullptr ) {
297+ ProgramInfo->RefCount ++;
298+ }
295299
296300 return UR_RESULT_SUCCESS;
297301}
@@ -364,6 +368,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink(
364368
365369 UR_CALL (pfnProgramLink (hContext, count, phPrograms, pOptions, phProgram));
366370
371+ UR_CALL (getAsanInterceptor ()->insertProgram (*phProgram));
367372 UR_CALL (getAsanInterceptor ()->registerProgram (*phProgram));
368373
369374 return UR_RESULT_SUCCESS;
@@ -395,6 +400,7 @@ ur_result_t UR_APICALL urProgramLinkExp(
395400 UR_CALL (pfnProgramLinkExp (hContext, numDevices, phDevices, count,
396401 phPrograms, pOptions, phProgram));
397402
403+ UR_CALL (getAsanInterceptor ()->insertProgram (*phProgram));
398404 UR_CALL (getAsanInterceptor ()->registerProgram (*phProgram));
399405
400406 return UR_RESULT_SUCCESS;
@@ -417,8 +423,7 @@ ur_result_t UR_APICALL urProgramRelease(
417423 UR_CALL (pfnProgramRelease (hProgram));
418424
419425 auto ProgramInfo = getAsanInterceptor ()->getProgramInfo (hProgram);
420- UR_ASSERT (ProgramInfo != nullptr , UR_RESULT_ERROR_INVALID_VALUE);
421- if (--ProgramInfo->RefCount == 0 ) {
426+ if (ProgramInfo != nullptr && --ProgramInfo->RefCount == 0 ) {
422427 UR_CALL (getAsanInterceptor ()->unregisterProgram (hProgram));
423428 UR_CALL (getAsanInterceptor ()->eraseProgram (hProgram));
424429 }
0 commit comments