From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 4D2984BD4B for ; Wed, 1 Oct 2025 16:21:40 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'aR4wGqiJiWyrhmVHpI8ckkaIY3Oti6ADRiBs5euHl1E=', expected b'b5bq8qupSSTIuZa0pYFp5AfifMvptSNuLf+egf9kcqc=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1759335684; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=aR4wGqiJiWyrhmVHpI8ckkaIY3Oti6ADRiBs5euHl1E=; b=4B/EvzrbCJXfZ4y5/3i/c65KvOQ9wphojDFB7dfg/Gdtb8ybCpTti/AS87AacKc9hDuh8 7eUYIYJ1GKvi3grTfRFxg9w748a6VUYrQSHFqhQ1D7ugodDIV3Kt/9WyJVn4dyAsUXRtAcY LgWhAWxc8bcV2BfeP2S98un87hsIWSTQCEujxAaVR2oFFM3w3z2FjjrRHdb3m45YBhPCVxk 6rHI55auKYFlDhxFj/0cUWmM/v3khXDBTEeqsIUaXx5OWWz4138JldIFxX9uasW+hD1KwZh f7mO8O2Ik/Zq3GXA4oriTDhUEkXgAQSM0gm6HP8Ja9J1vftiTIa9NaMGRhJA== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 5846D68EFA1; Wed, 1 Oct 2025 19:21:24 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1759335671; b=A7ERfV5rkXvjh5xZO4zejbCgkspc7uSNlcuhsdOWidpTLQHMqw5pratRxQ+bpswY9epYe GuyRbhAX56c5FjsS2RuNWm2aivpL29OpxI85cwT/h5t+W5933xbX144wZy63GraA5AtsPpt gUjH+GlB2oWLhI9PK3ef4zzMHvDgy4j1m8NFZ+oJk7v+I7fiwKEQ5JnyyWAqkcXM18ZreAU V2Ej11r29P/OUa+tqqIzBqW0rCEOe3/+NL/mLuyQa3OeUsngOn/7rv5gnjawOgFk2GGX2nO LBhtUkMLpwIgO2smAN796so5RQbclFQ+PeDp1u/9FhcLS1QtDlvHs/bz2Iqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1759335671; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=d9YwlpoarNLCSZbYRupzxyG+1ndBpAKGk2tb2wZA/I8=; b=jNtWSXG38OJtLKsBY0z34/AoCsluNPNmYL1ksTF1sT1KcP1PCXQk7i+6A1EZMPWIJx3tj 9t39foVxvDF4OPAiS2fuXP1dVCKokwOOntKWKSmYSt2CjzEkdk7DGhk5H7jSaLVUOHrxEXE SAaqCmUAmDJslfERt4Ih2m5g9HScu5RwUxnLe5EwCMxbDa+I5sTiQwCHGdmRaXzxDi+Bn7U hi2rnZGhFMgSS3Oan4aPNZELsYqGCPcrhWa1FaANfhzW9lPi/sa6uAHhz8HjCk24SKHvzAN qfemXMtKwjC0JJRT2XpywNUXQ8omjuffE1cJ9LexP1Cm8V4xvcYvMVrYds/A== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1759335665; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=b5bq8qupSSTIuZa0pYFp5AfifMvptSNuLf+egf9kcqc=; b=PAOKgrCKjMf21Nw5+TGPrUoIOsIftlSzp9xKdqWmZJFNNqfjINQfGk2Jc8sLyFkYAzdK8 8fg9YQFHamxKUvCJS2XkAfRc7P1XrT6hl7jmijPtORERlPA1P/KEDaJMCUO65QFkPpnuceV /sWwxSxF8UMSAR5ldtkUsRK4F12K3aXtCHB9gQF1Az6xGBWg2X+1tIoZP8tRwFIbOCqo+5q AvWdIzQlp0U7F9WksL/vwponzlB/m9bGI3mDG9U/BzmlbPtHr9wKlc7FxC6eH/Bzmqutta3 4lAwQ5EPcUVXwNyJXrK5qlHNnPVpEvmrkfYu6Ovlh7yUXpiRLuehCNINDbBQ== Received: from 13289e625de8 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id B16F568D6A5 for ; Wed, 1 Oct 2025 19:21:05 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Wed, 01 Oct 2025 16:21:05 -0000 Message-ID: <175933566584.69.1489205351262994685@bf249f23a2c8> Message-ID-Hash: AYCM4IPXOMFEYO7JAYY6RTMD5XSOWO3H X-Message-ID-Hash: AYCM4IPXOMFEYO7JAYY6RTMD5XSOWO3H X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] fftools: silence coverity race condition warning (PR #20638) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Niklas Haas via ffmpeg-devel Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20638 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20638 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20638.patch Avoids the following Coverity warning: > CID 1666425: Concurrent data access violations (MISSING_LOCK) > Accessing "fg->best_input" without holding lock "Scheduler.schedule_lock". > Elsewhere, "SchFilterGraph.best_input" is written to with > "Scheduler.schedule_lock" held 2 out of 2 times (2 of these accesses > strongly imply that it is necessary). I'm pretty sure this is a false positive, as `fg->best_input` is only ever written by the filter thread - so there's zero risk of concurrent write with this read. However, coverity seems to not be aware of this fact. To be honest, I'm not sure why it didn't trigger before, but possibly because the only other writing location before was in the same function, so maybe it was smart enough to understand that it can't race with itself. A mutex is nowehere near expensive enough that this once-per-frame extra lock/unlock is going to be in any way measurable. >>From 8248d22720e36edf1fc04269e047c5218526f14d Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 1 Oct 2025 18:15:48 +0200 Subject: [PATCH] fftools: silence coverity race condition warning Avoids the following Coverity warning: > CID 1666425: Concurrent data access violations (MISSING_LOCK) > Accessing "fg->best_input" without holding lock "Scheduler.schedule_lock". > Elsewhere, "SchFilterGraph.best_input" is written to with > "Scheduler.schedule_lock" held 2 out of 2 times (2 of these accesses > strongly imply that it is necessary). I'm pretty sure this is a false positive, as `fg->best_input` is only ever written by the filter thread - so there's zero risk of concurrent write with this read. However, coverity seems to not be aware of this fact. To be honest, I'm not sure why it didn't trigger before, but possibly because the only other writing location before was in the same function, so maybe it was smart enough to understand that it can't race with itself. A mutex is nowehere near expensive enough that this once-per-frame extra lock/unlock is going to be in any way measurable. --- fftools/ffmpeg_sched.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index d08f4a061d..5c52779588 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -2445,19 +2445,16 @@ int sch_filter_receive(Scheduler *sch, unsigned fg_idx, av_assert0(*in_idx <= fg->nb_inputs); - // update scheduling to account for desired input stream, if it changed - // - // this check needs no locking because only the filtering thread - // updates this value - if (*in_idx != fg->best_input) { - pthread_mutex_lock(&sch->schedule_lock); + pthread_mutex_lock(&sch->schedule_lock); + // update scheduling to account for desired input stream, if it changed + if (*in_idx != fg->best_input) { fg->best_input = *in_idx; schedule_update_locked(sch); - - pthread_mutex_unlock(&sch->schedule_lock); } + pthread_mutex_unlock(&sch->schedule_lock); + if (*in_idx == fg->nb_inputs) { int terminate = waiter_wait(sch, &fg->waiter); return terminate ? AVERROR_EOF : AVERROR(EAGAIN); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org