Skip to content

Two codepaths for OpenCL kernel are missing images.clear() #19134

@diablodale

Description

@diablodale

Two codepaths for OpenCL kernel are missing images.clear(). I noticed this during code review tracing memory cleanup.
The two missing paths are the synchronous codepaths. The async codepath has the clear() via a callback.

System information (version)
  • OpenCV => 4.5.0
  • Operating System / Platform => Windows 10 x64
  • Compiler => Visual Studio Community 2019 v16.8.3
Detailed description

In Kernel::Impl::run() the sync codepath has

*timeNS = -1;
}
}
cleanupUMats();
}

In Kernel::runTask() the sync codepath has

if (sync || retval != CL_SUCCESS)
{
CV_OCL_DBG_CHECK(clFinish(qq));
p->cleanupUMats();
}

Compare those to the async codepaths in those same functions. They both setup a callback like..

CV_OCL_CHECK(clSetEventCallback(asyncEvent, CL_COMPLETE, oclCleanupCallback, p));

and that callback within itself calls finit(e) which is...

void finit(cl_event e)
{
CV_UNUSED(e);
cleanupUMats();
images.clear();
isInProgress = false;
release();
}

The images.clear() is missing from the two sync codepaths. I think it should be added. 🤔 Yes?

Steps to reproduce
  1. Code review above
Fix

Add the two missing images.clear() calls in the two sync codepaths

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions