From: Junyan He Date: Mon, 6 Jan 2014 09:06:59 +0000 (+0800) Subject: Fix the multi-thread crash problem of batch buffer release. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=075816046c7147bc4277add300b54857a9af04fb;p=contrib%2Fbeignet.git Fix the multi-thread crash problem of batch buffer release. The case causes like this: our thread hold the ref of the batch buffer, but have called cl_driver_delete to delete the bufmgr. So when we release the buffer object next time, the bufmgr's function pointer is invalid and cause the crash. We now release the batch buffer before every time call the cl_set_thread_batch_buf. Signed-off-by: Junyan He Tested-by: "Yang, Rong R" --- diff --git a/src/cl_context.c b/src/cl_context.c index 1911bf2..8190e6a 100644 --- a/src/cl_context.c +++ b/src/cl_context.c @@ -203,6 +203,7 @@ cl_context_delete(cl_context ctx) assert(ctx->buffers == NULL); assert(ctx->drv); cl_free(ctx->prop_user); + cl_set_thread_batch_buf(NULL); cl_driver_delete(ctx->drv); ctx->magic = CL_MAGIC_DEAD_HEADER; /* For safety */ cl_free(ctx); diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 7452f10..30d1639 100644 --- a/src/cl_device_id.c +++ b/src/cl_device_id.c @@ -24,6 +24,7 @@ #include "cl_driver.h" #include "cl_device_data.h" #include "cl_khr_icd.h" +#include "cl_thread.h" #include "CL/cl.h" #include @@ -72,6 +73,7 @@ LOCAL cl_device_id cl_get_gt_device(void) { cl_device_id ret = NULL; + cl_set_thread_batch_buf(NULL); const int device_id = cl_driver_get_device_id(); #define DECL_INFO_STRING(STRUCT, FIELD, STRING) \