Skip to content

Commit 99763b1

Browse files
authored
[IE] Avoid race condition in IAsyncInferRequest (#30438)
### Details: - Added missing lock protections - Coverity issues: 1530042, 1530340 ### Tickets: - CVS-165933 Signed-off-by: Tomasz Jankowski <[email protected]>
1 parent 814f163 commit 99763b1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/inference/src/dev/iasync_infer_request.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void ov::IAsyncInferRequest::cancel() {
9999

100100
void ov::IAsyncInferRequest::set_callback(std::function<void(std::exception_ptr)> callback) {
101101
check_state();
102+
std::lock_guard<std::mutex> lock{m_mutex};
102103
m_callback = std::move(callback);
103104
}
104105

@@ -148,11 +149,12 @@ ov::threading::Task ov::IAsyncInferRequest::make_next_stage_task(
148149

149150
if ((itEndStage == itNextStage) || (nullptr != currentException)) {
150151
auto lastStageTask = [this, currentException]() mutable {
151-
auto promise = std::move(m_promise);
152+
std::promise<void> promise;
152153
std::function<void(std::exception_ptr)> callback;
153154
{
154155
std::lock_guard<std::mutex> lock{m_mutex};
155156
m_state = InferState::IDLE;
157+
promise = std::move(m_promise);
156158
std::swap(callback, m_callback);
157159
}
158160
if (callback) {

0 commit comments

Comments
 (0)