OpenCL-CTS icon indicating copy to clipboard operation
OpenCL-CTS copied to clipboard

Memory leak in `negative_command_ndrange_kernel_with_different_context`

Open gorazd-sumkovski-arm opened this issue 1 year ago • 0 comments

In the struct CommandNDRangeKernelKernelWithDifferentContext, the method CreateKernelWithDifferentContext() uses a helper function, create_single_kernel_helper_create_program(), which calls another helper. Every helper takes a cl_program * as an argument, but the program variable being used is actually a clProgramWrapper. I think this is the cause of the memory leak. Indeed replacing the call to create_single_kernel_helper_create_program() with a direct call to clCreateProgramWithSource() solves the issue. Changing the helpers to accept wrapper arguments is more than a trivial change because this will eventually require kernelHelpers.h to include typeWrappers.h but that causes cyclic inclusion with the headers as they currently are.

The relevant method in the wrapper class acknowledges it is not ideal to be doing things this way:

// Ideally this function should not exist as it breaks encapsulation by // allowing external mutation of the Wrapper internal state. However, too // much code currently relies on this. For example, instead of using T* as // output parameters, existing code can be updated to use Wrapper& instead. T *operator&() { return &object; }

gorazd-sumkovski-arm avatar Sep 04 '24 14:09 gorazd-sumkovski-arm