Valgrind invalid write hpp header: Memory releasing due to Program release

Hello,

I want to check my program for memory leaks (which may feel comfortable in cuda driver :confused: ).

However when executing I get this warning:

==17820== Invalid write of size 4

==17820==    at 0x15FBCDB6: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x15FBCED9: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1605BD5D: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1606153E: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16061AF9: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058724: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058BDA: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16061A2A: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x676CBCA: cl::detail::ReferenceHandler<_cl_mem*>::release(_cl_mem*) (cl.hpp:1051)

==17820==    by 0x676D606: cl::detail::Wrapper<_cl_mem*>::release() const (cl.hpp:1135)

==17820==    by 0x676CED3: cl::detail::Wrapper<_cl_mem*>::~Wrapper() (cl.hpp:1104)

==17820==    by 0x676CC3F: cl::Memory::~Memory() (cl.hpp:1687)

==17820==  Address 0x1581c598 is 24 bytes inside a block of size 104 free'd

==17820==    at 0x4C2457C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)

==17820==    by 0x15FED157: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x15FD5984: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x160603A1: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1606050B: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058764: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058BDA: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1605F7DA: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x67837B5: cl::detail::ReferenceHandler<_cl_program*>::release(_cl_program*) (cl.hpp:1069)

==17820==    by 0x678450A: cl::detail::Wrapper<_cl_program*>::release() const (cl.hpp:1135)

==17820==    by 0x6783B7D: cl::detail::Wrapper<_cl_program*>::~Wrapper() (cl.hpp:1104)

==17820==    by 0x6783886: cl::Program::~Program() (cl.hpp:2450)

==17820== 

==17820== Invalid write of size 8

==17820==    at 0x15FBCDBD: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x15FBCED9: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1605BD5D: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1606153E: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16061AF9: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058724: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058BDA: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16061A2A: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x676CBCA: cl::detail::ReferenceHandler<_cl_mem*>::release(_cl_mem*) (cl.hpp:1051)

==17820==    by 0x676D606: cl::detail::Wrapper<_cl_mem*>::release() const (cl.hpp:1135)

==17820==    by 0x676CED3: cl::detail::Wrapper<_cl_mem*>::~Wrapper() (cl.hpp:1104)

==17820==    by 0x676CC3F: cl::Memory::~Memory() (cl.hpp:1687)

==17820==  Address 0x1581c5b0 is 48 bytes inside a block of size 104 free'd

==17820==    at 0x4C2457C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)

==17820==    by 0x15FED157: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x15FD5984: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x160603A1: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1606050B: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058764: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x16058BDA: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x1605F7DA: ??? (in /usr/lib/libcuda.so.260.19.36)

==17820==    by 0x67837B5: cl::detail::ReferenceHandler<_cl_program*>::release(_cl_program*) (cl.hpp:1069)

==17820==    by 0x678450A: cl::detail::Wrapper<_cl_program*>::release() const (cl.hpp:1135)

==17820==    by 0x6783B7D: cl::detail::Wrapper<_cl_program*>::~Wrapper() (cl.hpp:1104)

==17820==    by 0x6783886: cl::Program::~Program() (cl.hpp:2450)

==17820==

Does cl::Program contain memory objects?

If yes: Where and how can I split this relationship?

I also observed that this warning vanishes when I omit the corresponding enqueueNDRangeKernel.

Any hints?

best regards,

Alex