Skip to content

Commit 58ef967

Browse files
committed
Check cache before clearing.
1 parent fd9c40a commit 58ef967

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/adapters/opencl/context.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ urContextRelease(ur_context_handle_t hContext) {
126126
CL_RETURN_ON_FAILURE(clGetContextInfo(clContext, CL_CONTEXT_REFERENCE_COUNT,
127127
sizeof(size_t), &refCount, nullptr));
128128

129-
if (refCount == 1) {
129+
// ExtFuncPtrCache is destroyed in an atexit() callback, so it doesn't
130+
// necessarily outlive the adapter (or all the contexts).
131+
if (refCount == 1 && cl_ext::ExtFuncPtrCache) {
130132
cl_ext::ExtFuncPtrCache->clearCache(clContext);
131133
}
132134
}

0 commit comments

Comments
 (0)