[Beignet] [PATCH] Fix event memory leak.
Zhigang Gong
zhigang.gong at linux.intel.com
Mon Jun 16 00:15:37 PDT 2014
Just as we discussed offline, I will ignore this patch as the original
issue should not be a library issue but a usage issue. We don't need to
fix it this way.
On Mon, Jun 16, 2014 at 02:45:55PM +0800, Zhigang Gong wrote:
> On Mon, Jun 16, 2014 at 10:59:36AM +0800, Yang Rong wrote:
> > Rlease old event when old event is a valid event.
> >
> > Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> > ---
> > src/cl_api.c | 5 ++++-
> > src/cl_utils.h | 3 +++
> > 2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/cl_api.c b/src/cl_api.c
> > index c8d3cee..4288fd1 100644
> > --- a/src/cl_api.c
> > +++ b/src/cl_api.c
> > @@ -79,8 +79,11 @@ handle_events(cl_command_queue queue, cl_int num, const cl_event *wait_list,
> > cl_event_get_timestamp(e, CL_PROFILING_COMMAND_QUEUED);
> > }
> >
> > - if(event != NULL)
> > + if(event != NULL) {
> > + if(IS_EVENT(*event))
> > + cl_event_delete(*event);
> After applied this patch, I noticed that the event may be just a input parameter which is used
> to pass back the event. And the *event is an uninitialized value, this IS_EVENT(*event) may refer
> to an uninitialized pointer and may cause segfault. Any idea?
>
> > *event = e;
> > + }
> > if(status == CL_ENQUEUE_EXECUTE_DEFER) {
> > cl_event_new_enqueue_callback(e, data, num, wait_list);
> > }
> > diff --git a/src/cl_utils.h b/src/cl_utils.h
> > index fa900a7..f2cd8a4 100644
> > --- a/src/cl_utils.h
> > +++ b/src/cl_utils.h
> > @@ -149,6 +149,9 @@ do { \
> > struct _cl_mem_image *IMAGE; \
> > IMAGE = cl_mem_image(MEM); \
> >
> > +#define IS_EVENT(EVENT) \
> > + ((EVENT) && (EVENT)->magic == CL_MAGIC_EVENT_HEADER)
> > +
> > #define CHECK_EVENT(EVENT) \
> > do { \
> > if (UNLIKELY(EVENT == NULL)) { \
> > --
> > 1.9.1
> >
> > _______________________________________________
> > Beignet mailing list
> > Beignet at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/beignet
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list