From patchwork Tue Jun 13 04:24:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 42056 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp3426301pzb; Mon, 12 Jun 2023 21:24:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VXH+8zRhWw/kNNzeFOPsQUyLxYPiuWE6mlyFbZQZ3M8SxfxQWlt+3+FMvNvVNr0bdpt37 X-Received: by 2002:aa7:cd10:0:b0:514:9e81:9068 with SMTP id b16-20020aa7cd10000000b005149e819068mr6024811edw.13.1686630258250; Mon, 12 Jun 2023 21:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686630258; cv=none; d=google.com; s=arc-20160816; b=bdURuCFvaeR2pZPbUUVXXeZmJlYccwDWnLAp2jSeob7Gt1EIwdvgGoL9NRy9N5i02E Az+b9LBD1O+mTVWLmFCfJCaflzaG2EgKU5rVtSDeKI/Do5DDEK5TrRqZBPDF4CH8MT6I jrf8dP+armKqMXz1YL+VhY6XP6+CTcEUdeDlSPVVqTU2VCv9Jqew2cDEAaylMJjs8QJM Y74tzD6NIdUGdrhu8RBURD7Msn7AbzPD0J03GtrMBwTwB2Rri5oah9l2NJF5vhszCldB ntLTiGa1tdwCF6wxkVvPX6VNfy/ZO6q2c3smIYiOocJTkr9Ykt0JJNcTkm76FsvW6EGI A1dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:to:from:date :dkim-signature:delivered-to; bh=PqRx9k89CZowNIFnJeKR2dm3rTW629o1u6fOPe4K7Yo=; b=H7VPEmdugmcyzRBNBzNxl9HIIKvElv7Ynds0oJ5waF1KdJflLCTPoWXcp7p+ziGzs0 XFo32/RzSXULyPVB6yD715ahGz9j2Tlzt3ENCmOLxExH119DM6uJLECS+w8jFNzdK3C7 8DUp6KVytvtwAeo1oAuLfkhbsAWgKJO/lbQ3dl44RrxAl0h9synIsTLtm/mli8aKnc7l iGAAiErUTDwSHIdC1d9gFWNr9T6msU60Cq5KraGqJMlPOIuPKMdznTuZ9wTn2htr9sbc F73/aYfzDl4ZKw0GMXgupb39wLnfEN29PuIRt7oi0Oy7ycB8+0KIrFkBkDKu+YpUK/f4 EN2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=H8gjCE7x; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w16-20020aa7d290000000b005187942d065si146192edq.692.2023.06.12.21.24.17; Mon, 12 Jun 2023 21:24:18 -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; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=H8gjCE7x; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38B3E68C37B; Tue, 13 Jun 2023 07:24:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 722B768AD1B for ; Tue, 13 Jun 2023 07:24:08 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 806511060154 for ; Tue, 13 Jun 2023 04:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1686630248; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=BhjxIVuKjeFe56A8wlI6ncK1/hawDxzO28dpC2Bo6s8=; b=H8gjCE7xTYZhQ8FylRypTKLxycaV1oZrmOAOmyEheKE7TXkDO+UbKoFHUTFfXYZi ZcBGIC2acfvM31mXtze55XsZn6fOJYGXiCF58SwsyAQDy0l+olhfshJ9xOcaKN1cLFP eMI4lhc7fyUfBnrsxD7cva9Q+xqymwegfP++wFKidOlJbUxY3VJW9Yp3nVP/Xr7puQW MvSImdl7SHKRd9BBcXcmof5ipWUZheyxzeDZ/p5+h3P8yIhGCcmdfD2HXjCvhiCOyEa QSVeulmcjtF+279cpz/+k/aSyF2UCG0iivfwpFiyMOOdJn2j2xZSqwFkaZGuwu+g1mY 2BMFTVXOTw== Date: Tue, 13 Jun 2023 06:24:08 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] vulkan_decode: fix small memory leak 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: Xr9J5RRW2jW2 This small memory leak was essentially responsible for keeping decoding working at all. The issue is that the codec profile must be attached to the frames context. We created the codec profile at decoder creation time. Which meant that if the decoder was destroyed, the context became essentially useless, and segfaulted as the profile was a hanging pointer. This was an issue that happened when seeking through H264. This requires using the new AVHWFramesContext.opaque field, as otherwise, the profile attached to the decoder will be freed before the frames context, rendering the frames context useless. Patch attached. From 7d8f1c73308dd29dbf2d46dc09d85808aa1cc6be Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 13 Jun 2023 06:13:10 +0200 Subject: [PATCH 5/5] vulkan_decode: fix small memory leak This requires using the new AVHWFramesContext.opaque field, as otherwise, the profile attached to the decoder will be freed before the frames context, rendering the frames context useless. --- libavcodec/vulkan_decode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index 81085273d8..5aad8b213b 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -584,6 +584,8 @@ static void free_common(void *opaque, uint8_t *data) s->hwctx->alloc); ff_vk_uninit(s); + + av_free(ctx); } static int vulkan_decode_bootstrap(AVCodecContext *avctx, AVBufferRef *frames_ref) -- 2.40.1