Skip to content

Commit

Permalink
Fix UB bug in extensions/cl_khr_command_buffer/command_buffer_event_s…
Browse files Browse the repository at this point in the history
…ync.cpp

RunCombufWaitForSecQueueCombuf() is launching two clEnqueueFillBuffer commands
on two separate queues, however both had the same buffer argument, and there
was no synchronization between the commands. Fixed the test to use separate
buffers for the two command queues.
  • Loading branch information
franz committed Nov 13, 2023
1 parent 62ec22a commit 4b4982e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ struct CommandBufferEventSync : public BasicCommandBufferTest
// due to possible out-of-order command queue copy the kernel for below
// case scenarios
if (event_mode == EventMode::RET_COMBUF_WAIT_FOR_SEC_COMBUF
|| event_mode == EventMode::RET_WAIT_FOR_SEC_QUEUE_EVENT
|| event_mode == EventMode::RET_CLWAITFOREVENTS)
{
kernel_sec = clCreateKernel(program, "copy", &error);
Expand All @@ -108,6 +109,7 @@ struct CommandBufferEventSync : public BasicCommandBufferTest
// due to possible out-of-order command queue it is necessary to create
// separate set of kernel args for below cases
if (event_mode == EventMode::RET_COMBUF_WAIT_FOR_SEC_COMBUF
|| event_mode == EventMode::RET_WAIT_FOR_SEC_QUEUE_EVENT
|| event_mode == EventMode::RET_CLWAITFOREVENTS)
{
// setup arguments for secondary kernel
Expand Down Expand Up @@ -570,13 +572,13 @@ struct CommandBufferEventSync : public BasicCommandBufferTest
test_error(error, "clCreateCommandBufferKHR failed");

// record secondary command buffer
error = RecordCommandBuffer(command_buffer_sec, kernel);
error = RecordCommandBuffer(command_buffer_sec, kernel_sec);
test_error(error, "RecordCommandBuffer failed");

// process secondary queue
error =
clEnqueueFillBuffer(queue_sec, in_mem, &pattern_pri, sizeof(cl_int),
0, data_size(), 0, nullptr, nullptr);
error = clEnqueueFillBuffer(queue_sec, in_mem_sec, &pattern_pri,
sizeof(cl_int), 0, data_size(), 0, nullptr,
nullptr);
test_error(error, "clEnqueueFillBuffer failed");

error = clEnqueueCommandBufferKHR(0, nullptr, command_buffer_sec, 0,
Expand Down

0 comments on commit 4b4982e

Please sign in to comment.