From patchwork Thu Sep 2 09:23:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Lhomme X-Patchwork-Id: 29947 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp100188iov; Thu, 2 Sep 2021 02:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY1hNhKeCSMSIcLeTG/ryG/ZaBVyyoSL1PqSMtSWIGzuc0gvV7HWUwY2Qr1BHkvbieqi7k X-Received: by 2002:a05:6402:1768:: with SMTP id da8mr2636493edb.80.1630574602920; Thu, 02 Sep 2021 02:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630574602; cv=none; d=google.com; s=arc-20160816; b=ZfLnHW3T9BJNfcFIaNJFJWye6YU2P75pQItB+Mk+tR+Bc6JVz+a7wrsMc2tg6tX4L1 ukK9PFaqMw3GaZG7momzFgvYSzbP+J6341NEUhm7DqknP/t/dYmW8mwiWsB7j1jbJKYo tk2WUq+NoMP9Q+FNoklJaLuN4Df1ZRsjshS27jbsbXXNGGPxY0KPy/vIZ00kYFQg6dnR a2fbMuz1oa+niOLUXb8LsTGjEOaBs8vg92qMsjUpfruPukckGt0EMy5hgQ8gBPlEYYFD PrJaKCRdoSsi2XruBaQ/HJ3hGq+WoIco2ROGxumoMvyJt8X794njyddDUJJWkFI2CEQp Q4AQ== 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=qNASwrDQP+y6J4YVRivJZT2oFcGPqBux84N6tUSlyYc=; b=WCEONituxSJ5N5i3kwsGDooXkmDGUqmxzw3hfIS79wEPdQZwksrCYRfbMPBV99mMCj 54Lm2nXO+lXZ554h9kVXMxGSpsDp5nuv8nkaFTcgKm5YcD8apTgYV+zuRmZzX4jPuPNg NuiZxkfAplgvIfx9BYl8mgqAI/mkQFLJHsg2w4lCZqVLDpetedxQLgkqNbmXTtfMJu2p jgWMg1hRTWPfCtj7d+TpynE59anETnscSNj1admYfr+YhQivwcUxC6Pl8hIYm6IDVAkx OLjN82daOGnT8U6MH4pamxPkMxDbg+KUK4De5apE/n9U0HuLQmL5Wpss3Yc371Snpvrw MZSw== 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 dc22si1492826edb.68.2021.09.02.02.23.22; Thu, 02 Sep 2021 02:23:22 -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 9EFFB680989; Thu, 2 Sep 2021 12:23:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02D5868A134 for ; Thu, 2 Sep 2021 12:23:13 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (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-102.mailbox.org (Postfix) with ESMTPS id 4H0b7h4zrtzQk25 for ; Thu, 2 Sep 2021 11:23:12 +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:23:22 +0200 Message-Id: <20210902092322.13352-1-robux4@ycbcr.xyz> MIME-Version: 1.0 X-Rspamd-Queue-Id: DD5491838 Subject: [FFmpeg-devel] [PATCH v3] 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: nHiLtF7eYaYL 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..f4af90eaec 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();