From patchwork Tue Jan 1 20:58:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 11629 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 15D6844DF08 for ; Tue, 1 Jan 2019 22:58:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BEAC268A353; Tue, 1 Jan 2019 22:58:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0034768A353 for ; Tue, 1 Jan 2019 22:58:38 +0200 (EET) Received: by mail-qt1-f179.google.com with SMTP id e5so31792096qtr.12 for ; Tue, 01 Jan 2019 12:58:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=TbqFJuqGmcACmZzSPj6FU7oIhH63keY3RVN8R9lkVLI=; b=j+O85hRMOi7LnXXa0el/GD6BxB6vM37sQf2E2ZkMXG+hF2V1uA/72Sn9VpE3fyJWmn LFtwzoUFLpl+Xasy6sZa5n+O0dk4aKxPTXHbRoj+62LsAbLKVR0ddzucxSQ4goZT7xN0 X2LfNG5obk940U5czBads3b0Std4NhXQ2U8XDceMY4sa2EfmMso/k+6r+efIybqd5Vev CneoZeSYL9Yn/uifOCxV3VRGnOGeTAqGOAdnSlY8+q6DNEdYUWXeRAmoue+e2VoyOgmG lL276Jnsy7/wZpVSz5un48zHkfYHtSM0l6rIWFcTTcZ8KsU+f4Q4F0PL2KW7ZLlErPO8 eJHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=TbqFJuqGmcACmZzSPj6FU7oIhH63keY3RVN8R9lkVLI=; b=l8yXna1h8h4ycl9IJWN0BX7QiGhU/X+PWnIttYow75473ep+yLLzNrRDdojQYER/kb GE3QdgjPOYo+J/mZocI7f7JjFzffCxKdKMFp6CXGmwV2wHGPDOpATp2L9rlPbQjGVMxG nkIEEsrWNORLkz0d1v04bErltsR3nLiooDlNtEOR55XOwcWVC52h1WYOu/tagE7SEA9j xoQOWXUuSoiD/ODRGDIpf3yHQ8JlmvLjJaN5i/96JdVe8nShCnEgzhzb5j6GI/5EnRYc CgWQ6w0MUnvhfcvUj8XnKF3rWLZz7CV7vBvXkQ4w8vmppsbOUSuRApPfJik4bOFPBo5w 7AWw== X-Gm-Message-State: AJcUukcszpNvUfQE/vkBnWsp+FFK4In6h5PrdowDMtpFPK/aDVebuX2a Grn4o+r3Vgsc9+gaA2JywHvq3fxE X-Google-Smtp-Source: ALg8bN7MLm1IJ4U6TGFtlfKIW2465WefgeiW1+s5ouiVtlxP6ELtJlxpIGgPqnEX7pB9j1meisWJcg== X-Received: by 2002:a0c:e610:: with SMTP id z16mr38869164qvm.81.1546376325579; Tue, 01 Jan 2019 12:58:45 -0800 (PST) Received: from [192.168.1.46] ([179.38.243.129]) by smtp.gmail.com with ESMTPSA id 5sm26663185qtw.50.2019.01.01.12.58.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Jan 2019 12:58:44 -0800 (PST) To: ffmpeg-devel@ffmpeg.org References: <54FC7158-A35F-41FE-AA48-4C0D66AFB456@mac.com> From: James Almer Openpgp: preference=signencrypt Message-ID: Date: Tue, 1 Jan 2019 17:58:42 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <54FC7158-A35F-41FE-AA48-4C0D66AFB456@mac.com> Content-Language: en-US Subject: Re: [FFmpeg-devel] Possible memory leaks in dshow capture X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" On 1/1/2019 5:01 PM, Oliver Collyer wrote: > ---------- Block 26224 at 0x0000000074240F70: 151 bytes ---------- > Leak Hash: 0x357CD5AF, Count: 1, Total 151 bytes > Call Stack (TID 55752): > ucrtbased.dll!aligned_malloc() > c:\ffmpeg\source\ffmpeg\libavutil\mem.c (90): emu-server.exe!av_malloc() + 0x10 bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_pin.c (213): emu-server.exe!libAVPin_Setup() + 0xA bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_pin.c (252): emu-server.exe!libAVPin_Create() + 0x9B bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_filter.c (184): emu-server.exe!libAVFilter_Setup() + 0xA bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_filter.c (198): emu-server.exe!libAVFilter_Create() + 0xA8 bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow.c (809): emu-server.exe!dshow_open_device() + 0x1C bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow.c (1150): emu-server.exe!dshow_read_header() + 0x18 bytes > c:\ffmpeg\source\ffmpeg\libavformat\utils.c (631): emu-server.exe!avformat_open_input() + 0x11 bytes > c:\users\oliver\perforce\non-si\emu\shared\dsdevice_streaming_session.cpp (1142): emu-server.exe!DSDEVICE_STREAMING_SESSION::CAPTURE_THREAD::thread_run() + 0x23 bytes > c:\users\oliver\perforce\non-si\emu\shared\thread_base.cpp (241): emu-server.exe!THREAD_BASE::thread_func() + 0xE bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\type_traits (16707566): emu-server.exe!std::_Invoker_functor::_Call() + 0x2B bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\type_traits (16707566): emu-server.exe!std::invoke() + 0x31 bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (239): emu-server.exe!std::_LaunchPad,std::default_delete > > >::_Execute<0,1>() > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (245): emu-server.exe!std::_LaunchPad,std::default_delete > > >::_Run() + 0x19 bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (231): emu-server.exe!std::_LaunchPad,std::default_delete > > >::_Go() > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (209): emu-server.exe!std::_Pad::_Call_func() > ucrtbased.dll!register_onexit_function() + 0x4A8 bytes > ucrtbased.dll!register_onexit_function() + 0xE1 bytes > KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes > ntdll.dll!RtlUserThreadStart() + 0x21 bytes > Data: > 70 0F 24 74 46 02 00 00 ED ED ED ED ED ED ED ED p.$tF... ........ > 36 DE C8 49 F7 7F 00 00 68 F0 CA 49 F7 7F 00 00 6..I.... h..I.... > 8D 99 CA 49 F7 7F 00 00 1F D6 C9 49 F7 7F 00 00 ...I.... ...I.... > C9 9E CA 49 F7 7F 00 00 B7 FD C8 49 F7 7F 00 00 ...I.... ...I.... > 22 EC C9 49 F7 7F 00 00 7E E1 C8 49 F7 7F 00 00 "..I.... ~..I.... > 3B 82 CA 49 F7 7F 00 00 CD CD CD CD CD CD CD CD ;..I.... ........ > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........ > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........ > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........ > CD CD CD CD CD CD CD ........ ........ > > > ---------- Block 26879 at 0x0000000074242E10: 151 bytes ---------- > Leak Hash: 0xA886255F, Count: 1, Total 151 bytes > Call Stack (TID 55752): > ucrtbased.dll!aligned_malloc() > c:\ffmpeg\source\ffmpeg\libavutil\mem.c (90): emu-server.exe!av_malloc() + 0x10 bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_pin.c (213): emu-server.exe!libAVPin_Setup() + 0xA bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_pin.c (252): emu-server.exe!libAVPin_Create() + 0x9B bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_filter.c (184): emu-server.exe!libAVFilter_Setup() + 0xA bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow_filter.c (198): emu-server.exe!libAVFilter_Create() + 0xA8 bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow.c (809): emu-server.exe!dshow_open_device() + 0x1C bytes > c:\ffmpeg\source\ffmpeg\libavdevice\dshow.c (1157): emu-server.exe!dshow_read_header() + 0x1E bytes > c:\ffmpeg\source\ffmpeg\libavformat\utils.c (631): emu-server.exe!avformat_open_input() + 0x11 bytes > c:\users\oliver\perforce\non-si\emu\shared\dsdevice_streaming_session.cpp (1142): emu-server.exe!DSDEVICE_STREAMING_SESSION::CAPTURE_THREAD::thread_run() + 0x23 bytes > c:\users\oliver\perforce\non-si\emu\shared\thread_base.cpp (241): emu-server.exe!THREAD_BASE::thread_func() + 0xE bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\type_traits (16707566): emu-server.exe!std::_Invoker_functor::_Call() + 0x2B bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\type_traits (16707566): emu-server.exe!std::invoke() + 0x31 bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (239): emu-server.exe!std::_LaunchPad,std::default_delete > > >::_Execute<0,1>() > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (245): emu-server.exe!std::_LaunchPad,std::default_delete > > >::_Run() + 0x19 bytes > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (231): emu-server.exe!std::_LaunchPad,std::default_delete > > >::_Go() > c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (209): emu-server.exe!std::_Pad::_Call_func() > ucrtbased.dll!register_onexit_function() + 0x4A8 bytes > ucrtbased.dll!register_onexit_function() + 0xE1 bytes > KERNEL32.DLL!BaseThreadInitThunk() + 0x14 bytes > ntdll.dll!RtlUserThreadStart() + 0x21 bytes > Data: > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........ > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........ > 10 2E 24 74 46 02 00 00 ED ED ED ED ED ED ED ED ..$tF... ........ > 36 DE C8 49 F7 7F 00 00 68 F0 CA 49 F7 7F 00 00 6..I.... h..I.... > 8D 99 CA 49 F7 7F 00 00 1F D6 C9 49 F7 7F 00 00 ...I.... ...I.... > C9 9E CA 49 F7 7F 00 00 B7 FD C8 49 F7 7F 00 00 ...I.... ...I.... > 22 EC C9 49 F7 7F 00 00 7E E1 C8 49 F7 7F 00 00 "..I.... ~..I.... > 3B 82 CA 49 F7 7F 00 00 CD CD CD CD CD CD CD CD ;..I.... ........ > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD ........ ........ > CD CD CD CD CD CD CD ........ ........ Does the attached (untested) patch fix these two for you? diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 664246da92..a4f64ed884 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -249,8 +249,16 @@ libAVPin_Setup(libAVPin *this, libAVFilter *filter) return 1; } + +static void +libAVPin_Free(libAVPin *this) +{ + if (!this) + return + av_freep(&this->imemvtbl); +} DECLARE_CREATE(libAVPin, libAVPin_Setup(this, filter), libAVFilter *filter) -DECLARE_DESTROY(libAVPin, nothing) +DECLARE_DESTROY(libAVPin, libAVPin_Free) /***************************************************************************** * libAVMemInputPin