[Beignet] [PATCH 1/3] Runtime: fix a recurrent release context error.
Yang Rong
rong.r.yang at intel.com
Tue Jun 20 11:07:45 UTC 2017
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 at intel.com>
---
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 c5f3678..f3dd421 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);
--
2.1.4
More information about the Beignet
mailing list