diff options
author | Yang, Rong R <rong.r.yang@intel.com> | 2017-06-20 19:07:45 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2017-07-10 17:21:04 +0800 |
commit | c909b00db08ade0c3cb123e776e52dbef6332596 (patch) | |
tree | d4ca00572f5418a5f59aa44c9ed080a4a1cfd485 | |
parent | f410c205bbeb28125fef4c3605fe15ef9285007d (diff) |
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 <rong.r.yang@intel.com>
Reviewed-by: Ruiling Song <ruiling.song@intel.com>
-rw-r--r-- | src/cl_context.c | 18 |
1 files 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); |