If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Check whether cl_mem object is valid

Thank you. My impression somehow was, that this should be the desired behavior - but I could not believe that there is such a rather dirty bug in the nVidia OpenCL implementation. I use a nVidia GTS 250 card with the developer driver version 270.81. I just realized that there is a newer driver release - I will check if this helps.

Re: Check whether cl_mem object is valid

Normal C conventions are to initialise pointers to NULL (which is always just 0), which will then be the same 0 result as from a failed allocation and treated the same way.

Then just test it before releasing it:

if (someimage) clReleaseMemObject(someimage);

If 'someimage' is a value on the stack, it will be initialised with completely random data. Checking the validity of pointers is too expensive to add to every call, so it's not surprising using a completely invalid pointer causes a crash.

Re: Check whether cl_mem object is valid

Even though initialization to NULL is a way to work around this, the implementation should still not segfault on encountering an invalid cl_mem object. I suggest you do report it to the manufacturer, although considering it's nvidia I don't know how much they'll care about it.