Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in negative_command_ndrange_kernel_with_different_context #2070

Open
gorazd-sumkovski-arm opened this issue Sep 4, 2024 · 0 comments

Comments

@gorazd-sumkovski-arm
Copy link
Contributor

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; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant