noah_r

cl_command_queue reference count does not track cl_event instances and leads to segmentation fault

Discussion created by noah_r on May 14, 2014
Latest reply on Jun 18, 2014 by pinform

I have discovered what I consider to be a bug in the reference tracking for cl_command_queue instances that leads to a segmentation fault under a reasonable usage scenario.

 

The cl_command_queue reference count is not incremented when a cl_event instance is created.  It should be.

 

clReleaseCommandQueue can be called while there are still cl_event instances that have not been released.  Now, in this case, it is still possible to get a reference to the command queue associated with cl_event by calling clGetEventInfo ( cl_event event, CL_EVENT_COMMAND_QUEUE, , &queue ... ).

 

I experience a segmentation fault if I use that queue reference to get information about the command queue,  for example:  clGetCommandQueueInfo( command_queue, CL_QUEUE_DEVICE, ...)

 

I've attached a bug demo program to demonstrate the error.

 

My output shows the queue reference count is unaffected by the event lifecycle:

$ g++ -o bugDemo command_queue_ref_cnt_demo.cpp bugDemoSupport.cpp -I /opt/AMDAPP/include -lOpenCL

$ ./bugDemo

Selected CL_PLATFORM_NAME: AMD Accelerated Parallel Processing

CL_DEVICE_NAME: AMD Opteron(TM) Processor 6274

CL_DRIVER_VERSION: 1214.3 (sse2,avx,fma4)

reference count after instantiation:       context 2, queue 1

reference count after creating an event:   context 4, queue 1

reference count after releasing the event: context 3, queue 1

 

 

The Apple implementation does not suffer this problem.  The queue reference count tracks the number of event instances associated with that queue:

$ ./bugDemo

Selected CL_PLATFORM_NAME: Apple

CL_DEVICE_NAME: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz

CL_DRIVER_VERSION: 1.1

reference count after instantiation:       context 2, queue 1

reference count after creating an event:   context 4, queue 2

reference count after releasing the event: context 3, queue 1

Outcomes