From 57fda7f2a8d8f3c047b08f00c45b218d1bd6be31 Mon Sep 17 00:00:00 2001 From: Maxim Shevtsov Date: Mon, 7 Dec 2020 16:58:26 +0300 Subject: [PATCH] fixed data race introduced in the https://github.com/openvinotoolkit/openvino/pull/3300 (#3490) it is easy to capture when there are 2 app-level inference requests, but only single worker (MULTI) request main thread | callback thread ___________________________________________________________________________ | | | 1) idleGuard.Release()->try_push(workerRequestPtr) 2) | 3) starts another request with StartAsync | ... 4) | workerInferRequest->_task = std::move(task); | if (_inferPipelineTasks.try_pop(workerRequestPtr->task)) the last line introduces DATA RACE (sporadically manifested in the bad_function_call exception), the fix is in this commit --- .../src/multi_device/multi_device_exec_network.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/multi_device/multi_device_exec_network.cpp b/inference-engine/src/multi_device/multi_device_exec_network.cpp index 10b9a280963..d9c1bf0a9b3 100644 --- a/inference-engine/src/multi_device/multi_device_exec_network.cpp +++ b/inference-engine/src/multi_device/multi_device_exec_network.cpp @@ -95,10 +95,11 @@ MultiDeviceExecutableNetwork::MultiDeviceExecutableNetwork(const DeviceMaptry_push(workerRequestPtr)) { + Task t; // try pop the task, as we know there is at least one idle request - if (_inferPipelineTasks.try_pop(workerRequestPtr->_task)) { + if (_inferPipelineTasks.try_pop(t)) { // if succeeded, let's schedule that - ScheduleToWorkerInferRequest(std::move(workerRequestPtr->_task)); + ScheduleToWorkerInferRequest(std::move(t)); } } });