From c909b00db08ade0c3cb123e776e52dbef6332596 Mon Sep 17 00:00:00 2001 From: "Yang, Rong R" Date: Tue, 20 Jun 2017 19:07:45 +0800 Subject: Runtime: fix a recurrent release context error. Before release internal resources, must set them to null, otherwize, when delete these resources, will call release context again. The ctx->built_in_prgs should be release by application. Signed-off-by: Yang Rong Reviewed-by: Ruiling Song --- src/cl_context.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/cl_context.c b/src/cl_context.c index c5f36781..f3dd4219 100644 --- a/src/cl_context.c +++ b/src/cl_context.c @@ -366,9 +366,6 @@ cl_context_delete(cl_context ctx) ++internal_ctx_refs; } - if (ctx->built_in_prgs) - ++internal_ctx_refs; - if (ctx->image_queue) ++internal_ctx_refs; @@ -382,30 +379,31 @@ cl_context_delete(cl_context ctx) CL_OBJECT_INC_REF(ctx); if (ctx->image_queue) { - clReleaseCommandQueue(ctx->image_queue); + cl_command_queue q = ctx->image_queue; ctx->image_queue = NULL; + clReleaseCommandQueue(q); } /* delete the internal programs. */ for (i = CL_INTERNAL_KERNEL_MIN; i < CL_INTERNAL_KERNEL_MAX; i++) { if (ctx->internal_kernels[i]) { - cl_kernel_delete(ctx->internal_kernels[i]); + cl_kernel k = ctx->internal_kernels[i]; ctx->internal_kernels[i] = NULL; + cl_kernel_delete(k); assert(ctx->internal_prgs[i]); - cl_program_delete(ctx->internal_prgs[i]); + cl_program p = ctx->internal_prgs[i]; ctx->internal_prgs[i] = NULL; + cl_program_delete(p); } if (ctx->built_in_kernels[i]) { - cl_kernel_delete(ctx->built_in_kernels[i]); + cl_kernel k = ctx->built_in_kernels[i]; ctx->built_in_kernels[i] = NULL; + cl_kernel_delete(k); } } - cl_program_delete(ctx->built_in_prgs); - ctx->built_in_prgs = NULL; - CL_OBJECT_DEC_REF(ctx); cl_free(ctx->prop_user); -- cgit v1.2.3