[FFmpeg-trac] #4819(avcodec:new): av_register_all() memory leak

FFmpeg trac at avcodec.org
Tue Sep 1 15:36:25 CEST 2015


#4819: av_register_all() memory leak
----------------------------------+---------------------------------------
             Reporter:  joeallen  |                     Type:  defect
               Status:  new       |                 Priority:  normal
            Component:  avcodec   |                  Version:  unspecified
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+---------------------------------------
 Originally I was making an application to convert audio to wav, and then I
 want to make sure it didn't leak, so I ran it with valgrind. There were a
 bunch of leaks but apparently av_register_all() is leaking memory. To
 confirm, I made a small test program:


 {{{
 #include <math.h>
 #include <string>
 #include <queue>
 #include <deque>
 #include <iostream>

 //#ifdef __cplusplus
 extern "C" {
 #ifndef __STDC_CONSTANT_MACROS
 #  define __STDC_CONSTANT_MACROS
 #endif
 #include <libavformat/avformat.h>
 #include <libavcodec/avcodec.h>
 #include <libswresample/swresample.h>
 #include <libswscale/swscale.h>
 #include <libavutil/channel_layout.h>
 #include <libavutil/common.h>
 #include <libavutil/imgutils.h>
 #include <libavutil/mathematics.h>
 #include <libavutil/avassert.h>
 #include <libavutil/avstring.h>
 #include <libavutil/frame.h>
 #include <libavutil/opt.h>
 #include <libavutil/samplefmt.h>
 #include <libavutil/timestamp.h>
 #include <libavfilter/avfilter.h>
 #include <libavfilter/buffersrc.h>
 #include <libavfilter/buffersink.h>
 #include <libavutil/dict.h>
 }


 int main (int argc, char ** argv){
     //Initialize all codecs
     av_register_all();
 }

 }}}

 Here is the valgrind output.

 {{{
 valgrind --leak-check=full --show-leak-kinds=all ./mfpeg
 ==2417== Memcheck, a memory error detector
 ==2417== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
 ==2417== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright
 info
 ==2417== Command: ./mfpeg
 ==2417==
 ==2417==
 ==2417== HEAP SUMMARY:
 ==2417==     in use at exit: 81 bytes in 2 blocks
 ==2417==   total heap usage: 4 allocs, 2 frees, 167 bytes allocated
 ==2417==
 ==2417== 32 bytes in 1 blocks are still reachable in loss record 1 of 2
 ==2417==    at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-
 amd64-linux.so)
 ==2417==    by 0x6DE768F: _dlerror_run (dlerror.c:141)
 ==2417==    by 0x6DE70C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
 ==2417==    by 0x8DC7273: x265_api_get_63 (in
 /usr/local/lib/libx265.so.63)
 ==2417==    by 0x5958E74: ??? (in /usr/local/lib/libavcodec.so.56.41.100)
 ==2417==    by 0x59D76B1: avcodec_register_all (in
 /usr/local/lib/libavcodec.so.56.41.100)
 ==2417==    by 0x4E6B342: av_register_all (in
 /usr/local/lib/libavformat.so.56.36.100)
 ==2417==    by 0x400830: main (main.cpp:35)
 ==2417==
 ==2417== 49 bytes in 1 blocks are still reachable in loss record 2 of 2
 ==2417==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-
 amd64-linux.so)
 ==2417==    by 0x400FDC0: _dl_signal_error (dl-error.c:90)
 ==2417==    by 0x40146CF: _dl_open (dl-open.c:715)
 ==2417==    by 0x6DE702A: dlopen_doit (dlopen.c:66)
 ==2417==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
 ==2417==    by 0x6DE762C: _dlerror_run (dlerror.c:163)
 ==2417==    by 0x6DE70C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
 ==2417==    by 0x8DC7273: x265_api_get_63 (in
 /usr/local/lib/libx265.so.63)
 ==2417==    by 0x5958E74: ??? (in /usr/local/lib/libavcodec.so.56.41.100)
 ==2417==    by 0x59D76B1: avcodec_register_all (in
 /usr/local/lib/libavcodec.so.56.41.100)
 ==2417==    by 0x4E6B342: av_register_all (in
 /usr/local/lib/libavformat.so.56.36.100)
 ==2417==    by 0x400830: main (main.cpp:35)
 ==2417==
 ==2417== LEAK SUMMARY:
 ==2417==    definitely lost: 0 bytes in 0 blocks
 ==2417==    indirectly lost: 0 bytes in 0 blocks
 ==2417==      possibly lost: 0 bytes in 0 blocks
 ==2417==    still reachable: 81 bytes in 2 blocks
 ==2417==         suppressed: 0 bytes in 0 blocks
 ==2417==
 ==2417== For counts of detected and suppressed errors, rerun with: -v
 ==2417== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

 }}}

 I made a stackoverflow post on it:
 http://stackoverflow.com/questions/32323093/ffmpeg-av-register-all-memory-
 leak

 It seems to be an issue with x265 codec. Any help would be appreciated.
 Thanks.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/4819>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list