Bugzilla – Bug 296
cl.hpp: reference counting bug
Last modified: 2011-08-30 09:17:08 PDT
<Please comment on your experience with the C++ bindings to OpenCL 1.0 here, including any bugs you encounter as well as suggestions for improvement. If you are having problems, please try to provide a complete example including source code demonstrating the problem as well as describing the OS, C++ compiler, and compiler options used.>
(In reply to comment #0) > <Please comment on your experience with the C++ bindings to OpenCL 1.0 here, > including any bugs you encounter as well as suggestions for improvement. If > you are having problems, please try to provide a complete example including > source code demonstrating the problem as well as describing the OS, C++ > compiler, and compiler options used.> Sorry, didn't expect that clicking the back button discards the text, so here it is: cl::CommandQueue::getInfo<CL_QUEUE_CONTEXT>() doesn't increase the reference count of the cl::Context object returned by this method. This results in a program crash when the destructur is called for the unreferenced instance. The problem probably exists for other getInfo<...> variants since the code is shared. This file demonstrates the problem. The program crashes in ReferenceHandler<cl_context>::release(), which is invoked from cl::Context::~Context(). If the context's reference count is increased explicitly (by setting "#if 1" in line 47), the program finishes without error.
Created attachment 40 [details] demonstrate reference counting bug
This is a known problem and something we are working on, unlike many of the other bugs it does not have a straightforward solution.
I see. Is there a public discussion on this issue elsewhere? I would like to contribute since the workaround I'm currently using is quite ugly :-)
There is general discussion of the C++ bindings on the OpenCL forum here: http://www.khronos.org/message_boards/viewtopic.php?f=28&t=1415
Created attachment 41 [details] proposed patch for reference counting bug This is a proposed patch for this issue: *) define a template function "fixReferenceCount()" which does nothing *) overload this function for all relevant types (e.g., cl::Context), and call their retain() method *) call "fixReferenceCount()" for data returned by the native OpenCL functions (in GetInfoHelper::get())
This post says reference counting was fixed: http://www.khronos.org/message_boards/viewtopic.php?p=7692#p7692 Can the OP confirm?
Reference counting is fixed and so closing.