From 33ac0ca199aaeb48067cef9eef09bbbea6faf622 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 13 Oct 2026 06:10:50 +0200 Subject: [PATCH] avfilter/dnn_backend_openvino: wait only for the inference requests that were created Fixes: nC3u8khGyx61 Fixes: hang on teardown Hang on teardown Replicated through UnModified FFmpeg with gdb Hang on teardown Replicated through UnModified FFmpeg with gdb, a crafted 10240x10240 PNG, input_resizable=1 and vm.overcommit_memory=2 Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24617 --- libavfilter/dnn/dnn_backend_openvino.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 9b83670a71..180e61bbfa 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -62,6 +62,7 @@ typedef struct OVModel{ Queue *task_queue; // holds TaskItem Queue *lltask_queue; // holds LastLevelTaskItem int nb_outputs; + int nb_requests; } OVModel; // one request for one call to openvino @@ -516,7 +517,7 @@ static void dnn_free_model_ov(DNNModel **model) return; ov_model = (OVModel *)(*model); - ff_dnn_wait_requests(ov_model->request_queue, ov_model->ctx->nireq); + ff_dnn_wait_requests(ov_model->request_queue, ov_model->nb_requests); while (ff_safe_queue_size(ov_model->request_queue) != 0) { OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue); if (item && item->infer_request) { @@ -910,6 +911,7 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * ret = AVERROR(ENOMEM); goto err; } + ov_model->nb_requests++; #if HAVE_OPENVINO2 status = ov_compiled_model_create_infer_request(ov_model->compiled_model, &item->infer_request);