From patchwork Tue Sep 12 11:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Guillem X-Patchwork-Id: 43710 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4e27:b0:149:dfde:5c0a with SMTP id gk39csp2721199pzb; Tue, 12 Sep 2023 04:40:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYlkQvYGzL+EP/RXlnTLef3xYfgRC/oY57bo/xldLUXOYfp9AP8CoNfAGvlDLLzjJl0wVW X-Received: by 2002:a05:6512:31c5:b0:502:a588:6609 with SMTP id j5-20020a05651231c500b00502a5886609mr10648447lfe.3.1694518844711; Tue, 12 Sep 2023 04:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694518844; cv=none; d=google.com; s=arc-20160816; b=QXRzE3AFIVmfAvafokV7mTd4YVn6yw2OUSIHIHm3JX47aCxDRS8FV5vDkYHlvFdlV0 jtc2mrOlD8A2P0cDRkD5KRHHdW4V0a5qhlx5Y//ims0FOLbHJAmbjOkI0umo7plBrVRW rOCt2V4Pi/0/cMpqc7mXov1BZhDh5258q7xkjH4wFxveCWsCJEqzR/oxJgSGlTJ5PL9N 9v7/Yf5vK4G4Kred9sDwQYIwXlr//jdYRe3T0Q9bySv4ENL3ZHXYgPXraOL/RNp+u4o4 SvFm0EKKJlJ4bLMroTtrNnAmaNW6SnrVN/YaIie8E8B4MpAmwkSpeJE3NmE90+k0R9XS a+IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:feedback-id:delivered-to; bh=HfPr1xLWmIdxfBshZaugZ6KuTPHTJccuoAWk48ya9Wk=; fh=3LY024vSFS/PP4LTfcCy63MQoPE5JAibP23dzfT0gvE=; b=IpIQ1tVuIHdW9QNqg46tzrcML92ZXXXE5u9WoE1B7d0RHt3WhflOXhGT55v1Koiu68 35oGp5tgyW+/gY/RDA4SCr8leGrbeV8K7qYgc9jSgcv5o7yQNiewUTV+11VTE6M+1BTf 9h1C2eGB/qXpoyRG/6Gfgrm8FUCPtoQMqGNZ+rxfi5Z11hDdqu0KU6+GRb6RJoV4Y9fS 4wRcpv1Sw4UTefQ0Tbxs016z6nON7PXwCZqLrB9JsMZsHFxR4+l19BMt9c8QNs2rT9Cv iVL3tznNsXqiwh7AFrTtJMfliPTN29aX88+9z+LK5eLe/zL9bgLfLb7WpP3Fu3Im9Mj5 iBFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i1-20020a50fc01000000b0052a0fd83709si7787453edr.540.2023.09.12.04.40.43; Tue, 12 Sep 2023 04:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33BB468C96E; Tue, 12 Sep 2023 14:40:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2DC1E68C92F for ; Tue, 12 Sep 2023 14:40:21 +0300 (EEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4EFE35C02E7 for ; Tue, 12 Sep 2023 07:40:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 12 Sep 2023 07:40:20 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeiiedggeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfiuhhilhhlvghmuceothhhohhmrghssehg lhhlmhdrfhhrqeenucggtffrrghtthgvrhhnpeejieegveejteejteegvdfhjeeffeehfe efuddvhfffleegfeehleekudekleefleenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesghhllhhmrdhfrh X-ME-Proxy: Feedback-ID: i239440f1:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 12 Sep 2023 07:40:19 -0400 (EDT) To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Sep 2023 13:40:15 +0200 Message-Id: <20230912114015.59937-3-thomas@gllm.fr> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230912114015.59937-1-thomas@gllm.fr> References: <20230912114015.59937-1-thomas@gllm.fr> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] h264: fix data-race with FF_DECODE_ERROR_DECODE_SLICES X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Thomas Guillem via ffmpeg-devel From: Thomas Guillem Reply-To: FFmpeg development discussions and patches Cc: Thomas Guillem Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: D/ndzw06CiIF Same than the previous commit but with FF_DECODE_ERROR_DECODE_SLICES Fix the following data-race: WARNING: ThreadSanitizer: data race (pid=55935) Write of size 4 at 0x7b5000009378 by thread T1 (mutexes: write M608): #0 decode_nal_units src/libavcodec/h264dec.c:742 (ffmpeg+0xb19dd6) #1 h264_decode_frame src/libavcodec/h264dec.c:1016 (ffmpeg+0xb19dd6) #2 frame_worker_thread src/libavcodec/pthread_frame.c:228 (ffmpeg+0xdeea7e) Previous read of size 4 at 0x7b5000009378 by thread T14 (mutexes: write M610): #0 frame_copy_props src/libavutil/frame.c:321 (ffmpeg+0x1793759) #1 av_frame_replace src/libavutil/frame.c:530 (ffmpeg+0x1794714) #2 ff_thread_replace_frame src/libavcodec/utils.c:898 (ffmpeg+0xfb1d0f) #3 ff_h264_replace_picture src/libavcodec/h264_picture.c:159 (ffmpeg+0x149cd3d) #4 ff_h264_update_thread_context src/libavcodec/h264_slice.c:413 (ffmpeg+0x14abf04) #5 update_context_from_thread src/libavcodec/pthread_frame.c:355 (ffmpeg+0xdec39c) #6 submit_packet src/libavcodec/pthread_frame.c:494 (ffmpeg+0xdecee3) #7 ff_thread_decode_frame src/libavcodec/pthread_frame.c:545 (ffmpeg+0xdecee3) #8 decode_simple_internal src/libavcodec/decode.c:431 (ffmpeg+0x9e1e20) #9 decode_simple_receive_frame src/libavcodec/decode.c:607 (ffmpeg+0x9e1e20) #10 decode_receive_frame_internal src/libavcodec/decode.c:635 (ffmpeg+0x9e1e20) #11 avcodec_send_packet src/libavcodec/decode.c:732 (ffmpeg+0x9e28fa) #12 packet_decode src/fftools/ffmpeg_dec.c:555 (ffmpeg+0x229888) #13 decoder_thread src/fftools/ffmpeg_dec.c:702 (ffmpeg+0x229888) --- libavcodec/h264dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 24e849fc5b..b82ca8f14f 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -739,7 +739,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) // set decode_error_flags to allow users to detect concealed decoding errors if ((ret < 0 || h->er.error_occurred) && h->cur_pic_ptr) { - h->cur_pic_ptr->f->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES; + h->cur_pic_ptr->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES; } ret = 0;