From patchwork Thu Sep 2 09:02:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Lhomme X-Patchwork-Id: 29946 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp85797iov; Thu, 2 Sep 2021 02:03:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvCXQwoZU3dJPUcCBkYRCH709vqMpP66nLHgrrjszBB9okoIBzAJYWvwpsWUbhUXQJxN3M X-Received: by 2002:a17:906:909:: with SMTP id i9mr2649972ejd.16.1630573383690; Thu, 02 Sep 2021 02:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630573383; cv=none; d=google.com; s=arc-20160816; b=XzKWivnmnLxsNB7YdHB5b9GJS2tM/P/OZmnKa4Mvh7mwbmJwyQpvXkpKP9jcxnOKOQ CS6t9Ko8EuMRXv5FQadsNUnQXBo3Z0qTcwP1XyU9g/VW9oCbnWaOKmg5MamR+RXQEh6O 2nVqCF9Uj5Hls0m9l2D9oxAnekKAfptzkoL9KixT/HxirrquJJjtuirDKiMSba1isb7F 7IVPFldQ4RSXImiwLFVOl7BrIsj9JpnOvTAxincobXQuIyRnbNc41QqViM1Rm+0X6YRl w+nsdq2+ojoMuoQyY//KgR7dLpK5I2ho2SNdsdDjn5v4OhCizxUL8vdTm7Kcv+8tTfwN 74HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=6o5UM9sfmGs6W+cZGb8rrlRdUziNPAYvDtHbN/HIG5g=; b=u6+053fRQw1RtL07hjKgegjyxz/QkDfaRNB9l8WpBlbu/ggRapyuwx0f+mL9zi1oyv PqaQRnrYyETSan6rrxQMRuszVmVYLiVsrxPorsX10z1UatzRIs54iJVZ3rpA8jJERvzx zcnzI1+wV7mEEiZW3wLvNJYFIrlPe+LsdMAmf1+KaI7dwvnsPDYLNbNXKtw5tDWyugRX 5+xcAVGT7gEd1rq8fW7bUIekKlmv9o4mU5k2dk45E3zY1VOStkdlNMzh8CPDVa20+CEt 59qOK7L751zabE4YzkNJ0OxT98ymcW3M29ZenwmWTRu9PHdHP1EUyfWGrpZLPdYii5uM 60cA== 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 yc17si1263577ejb.381.2021.09.02.02.02.39; Thu, 02 Sep 2021 02:03:03 -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 075C368A26E; Thu, 2 Sep 2021 12:02:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AAAA568A13F for ; Thu, 2 Sep 2021 12:02:28 +0300 (EEST) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4H0Zgl6QfMzQlRT for ; Thu, 2 Sep 2021 11:02:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de From: Steve Lhomme To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Sep 2021 11:02:28 +0200 Message-Id: <20210902090228.13132-1-robux4@ycbcr.xyz> MIME-Version: 1.0 X-Rspamd-Queue-Id: 295AF1887 Subject: [FFmpeg-devel] [PATCH] avcodec/vp9: avoid using uninitialized mutex/condition 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: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: hrPBQ/mWk1JD When using slice decoding vp9_free_entries is called before vp9_alloc_entries is ever called. It should destroy properly initialized variables (or check it was never called before). It usually works undetected as pthread implementations allows NULL as a special value (and should return EINVAL but doesn't). But pthreadGC2 doesn't allow NULL in pthread_mutex_destroy() and crashes when that's the case. --- libavcodec/vp9.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 874005a5ae..d40e90b70e 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1796,6 +1796,10 @@ static av_cold int vp9_decode_init(AVCodecContext *avctx) s->last_bpp = 0; s->s.h.filter.sharpness = -1; + if (avctx->active_thread_type & FF_THREAD_SLICE) { + pthread_mutex_init(&s->progress_mutex, NULL); + pthread_cond_init(&s->progress_cond, NULL); + } for (int i = 0; i < 3; i++) { s->s.frames[i].tf.f = av_frame_alloc();