From a3520f04801d4f1b5b99ea788ab696a79afa3e40 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Fri, 6 Feb 2015 17:48:15 +0800 Subject: runtime: don't free the host_ptr for a subbuffer. When the buffer has CL_MEM_ALLOC_HOST_PTR, the runtime need to free the host_ptr at destructor. But if the buffer is a subbuffer, then its host ptr is not allocated by itself, we should not free it here. Otherwise, it may cause some weird errors such as: "corrupted double-linked list..". Signed-off-by: Zhigang Gong Reviewed-by: "Guo, Yejun" --- src/cl_mem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cl_mem.c b/src/cl_mem.c index 5243efec..d2e502d1 100644 --- a/src/cl_mem.c +++ b/src/cl_mem.c @@ -1127,7 +1127,9 @@ cl_mem_delete(cl_mem mem) cl_buffer_unreference(mem->bo); } - if (mem->is_userptr && (mem->flags & CL_MEM_ALLOC_HOST_PTR)) + if (mem->is_userptr && + (mem->flags & CL_MEM_ALLOC_HOST_PTR) && + (mem->type != CL_MEM_SUBBUFFER_TYPE)) cl_free(mem->host_ptr); cl_free(mem); -- cgit v1.2.1