From 5ef505673ae9855df34cd5fd232b3fd4018f8811 Mon Sep 17 00:00:00 2001 From: Michal Babej Date: Sat, 4 Nov 2023 19:30:59 +0200 Subject: [PATCH] Fix UB bug in extensions/cl_khr_command_buffer/command_buffer_event_sync.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. --- .../command_buffer_event_sync.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp index 6ef26bb9fa..2f76e2fe69 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp @@ -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); @@ -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 @@ -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,