[FFmpeg-trac] #3219(avcodec:new): Frame ref count behaviour change causing a memleak

FFmpeg trac at avcodec.org
Wed Dec 11 16:59:58 CET 2013


#3219: Frame ref count behaviour change causing a memleak
-------------------------------------+-------------------------------------
               Reporter:  ubitux     |                  Owner:
                   Type:  defect     |                 Status:  new
               Priority:  normal     |              Component:  avcodec
                Version:  git-       |               Keywords:  regression
  master                             |  examples
             Blocked By:             |               Blocking:
Reproduced by developer:  0          |  Analyzed by developer:  0
-------------------------------------+-------------------------------------
 Since 7a901eb33 / 37a749012 the demuxing_decoding example is leaking with
 the default method (old API):

 {{{
 ☭ ./ffmpeg -f lavfi -i testsrc -t 5 -y test.mpg
 ffmpeg version N-58970-g7f39352 Copyright (c) 2000-2013 the FFmpeg
 developers
   built on Dec 11 2013 16:50:39 with gcc 4.8.2 (GCC)
   configuration: --enable-gpl --enable-libx264 --enable-libmp3lame
 --enable-x11grab --enable-libvorbis --samples=/home/ux/fate-samples
 --enable-libvpx --cpu=native --cc='ccache cc' --disable-doc
   libavutil      52. 58.100 / 52. 58.100
   libavcodec     55. 45.100 / 55. 45.100
   libavformat    55. 22.100 / 55. 22.100
   libavdevice    55.  5.102 / 55.  5.102
   libavfilter     3. 92.100 /  3. 92.100
   libswscale      2.  5.101 /  2.  5.101
   libswresample   0. 17.104 /  0. 17.104
   libpostproc    52.  3.100 / 52.  3.100
 Input #0, lavfi, from 'testsrc':
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240
 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
 [mpeg @ 0x2f61c20] VBV buffer size not set, muxing may fail
 Output #0, mpeg, to 'test.mpg':
   Metadata:
     encoder         : Lavf55.22.100
     Stream #0:0: Video: mpeg1video, yuv420p, 320x240 [SAR 1:1 DAR 4:3],
 q=2-31, 200 kb/s, 90k tbn, 25 tbc
 Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo -> mpeg1video)
 Press [q] to stop, [?] for help
 frame=  125 fps=0.0 q=2.4 Lsize=     216kB time=00:00:04.96 bitrate=
 356.7kbits/s
 video:212kB audio:0kB subtitle:0 global headers:0kB muxing overhead
 1.748527%
 }}}

 {{{
 ☭ (cd doc/examples && PKG_CONFIG_PATH=pc-uninstalled make clean &&
 PKG_CONFIG_PATH=pc-uninstalled make demuxing_decoding && valgrind --leak-
 check=full ./demuxing_decoding -refcount=old ../../test.mpg /dev/null
 /dev/null > /dev/null)
 rm -f test*.pgm test.h264 test.mp2 test.sw test.mpg
 rm -f decoding_encoding demuxing_decoding filtering_video filtering_audio
 metadata muxing resampling_audio scaling_video transcode_aac
 decoding_encoding.o demuxing_decoding.o filtering_video.o
 filtering_audio.o metadata.o muxing.o resampling_audio.o scaling_video.o
 transcode_aac.o
 cc -Ipc-uninstalled/../../..  -Wall -g   -c -o demuxing_decoding.o
 demuxing_decoding.c
 demuxing_decoding.c: In function ‘main’:
 demuxing_decoding.c:300:9: warning: ‘avcodec_alloc_frame’ is deprecated
 (declared at pc-uninstalled/../../../libavcodec/avcodec.h:3384)
 [-Wdeprecated-declarations]
          frame = avcodec_alloc_frame();
          ^
 cc   demuxing_decoding.o  -Lpc-uninstalled/../../../libavdevice -Lpc-
 uninstalled/../../../libavfilter -Lpc-uninstalled/../../../libpostproc
 -Lpc-uninstalled/../../../libavformat -Lpc-uninstalled/../../../libavcodec
 -Lpc-uninstalled/../../../libswresample -Lpc-
 uninstalled/../../../libswscale -Lpc-uninstalled/../../../libavutil
 -Wl,-rpath,pc-uninstalled/../../../libavdevice -lavdevice -ldl -lXv -lX11
 -lXext -lvdpau -lva -lXfixes -lXext -lX11 -ljack -lasound -lSDL -lpthread
 -lx264 -lvpx -lvorbisenc -lvorbis -logg -lmp3lame -lm -pthread -lbz2 -lz
 -Wl,-rpath,pc-uninstalled/../../../libavfilter -lavfilter -ldl -lXv -lX11
 -lXext -lvdpau -lva -lXfixes -lXext -lX11 -ljack -lasound -lSDL -lpthread
 -lx264 -lvpx -lvorbisenc -lvorbis -logg -lmp3lame -lm -pthread -lbz2 -lz
 -Wl,-rpath,pc-uninstalled/../../../libpostproc -lpostproc -Wl,-rpath,pc-
 uninstalled/../../../libavformat -lavformat -ldl -lXv -lX11 -lXext -lvdpau
 -lva -lXfixes -lXext -lX11 -ljack -lasound -lSDL -lpthread -lx264 -lvpx
 -lvorbisenc -lvorbis -logg -lmp3lame -lm -pthread -lbz2 -lz -Wl,-rpath,pc-
 uninstalled/../../../libavcodec -lavcodec -ldl -lXv -lX11 -lXext -lvdpau
 -lva -lXfixes -lXext -lX11 -ljack -lasound -lSDL -lpthread -lx264 -lvpx
 -lvorbisenc -lvorbis -logg -lmp3lame -lm -pthread -lbz2 -lz -Wl,-rpath,pc-
 uninstalled/../../../libswresample -lswresample -lm -Wl,-rpath,pc-
 uninstalled/../../../libswscale -lswscale -lm -Wl,-rpath,pc-
 uninstalled/../../../libavutil -lavutil -lm   -o demuxing_decoding
 ==31771== Memcheck, a memory error detector
 ==31771== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
 ==31771== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright
 info
 ==31771== Command: ./demuxing_decoding -refcount=old ../../test.mpg
 /dev/null /dev/null
 ==31771==
 Could not find audio stream in input file '../../test.mpg'
 Input #0, mpeg, from '../../test.mpg':
   Duration: 00:00:04.92, start: 0.540000, bitrate: 359 kb/s
     Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 320x240 [SAR 1:1
 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc
 ==31771==
 ==31771== HEAP SUMMARY:
 ==31771==     in use at exit: 60,368 bytes in 748 blocks
 ==31771==   total heap usage: 7,916 allocs, 7,168 frees, 3,161,169 bytes
 allocated
 ==31771==
 ==31771== 64 (8 direct, 56 indirect) bytes in 1 blocks are definitely lost
 in loss record 4 of 12
 ==31771==    at 0x4C27730: malloc (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==31771==    by 0x4C29B0F: realloc (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==31771==    by 0xA6EA45: av_frame_copy_props (frame.c:560)
 ==31771==    by 0x89CB89: unrefcount_frame.isra.3 (utils.c:2043)
 ==31771==    by 0x8A02B2: avcodec_decode_video2 (utils.c:2144)
 ==31771==    by 0x44AC97: decode_packet (demuxing_decoding.c:77)
 ==31771==    by 0x44B83B: main (demuxing_decoding.c:336)
 ==31771==
 ==31771== 7,936 (992 direct, 6,944 indirect) bytes in 124 blocks are
 definitely lost in loss record 10 of 12
 ==31771==    at 0x4C27730: malloc (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==31771==    by 0x4C29B0F: realloc (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==31771==    by 0xA6EA45: av_frame_copy_props (frame.c:560)
 ==31771==    by 0x89CB89: unrefcount_frame.isra.3 (utils.c:2043)
 ==31771==    by 0x8A02B2: avcodec_decode_video2 (utils.c:2144)
 ==31771==    by 0x44AC97: decode_packet (demuxing_decoding.c:77)
 ==31771==    by 0x44B7B0: main (demuxing_decoding.c:323)
 ==31771==
 ==31771== 52,328 (2,976 direct, 49,352 indirect) bytes in 124 blocks are
 definitely lost in loss record 12 of 12
 ==31771==    at 0x4C29D00: memalign (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==31771==    by 0x4C29E17: posix_memalign (in /usr/lib/valgrind
 /vgpreload_memcheck-amd64-linux.so)
 ==31771==    by 0xA73E9F: av_mallocz (mem.c:94)
 ==31771==    by 0xA6661D: av_buffer_ref (buffer.c:93)
 ==31771==    by 0xA6EBE0: av_frame_copy_props (frame.c:509)
 ==31771==    by 0x89CB89: unrefcount_frame.isra.3 (utils.c:2043)
 ==31771==    by 0x8A02B2: avcodec_decode_video2 (utils.c:2144)
 ==31771==    by 0x44AC97: decode_packet (demuxing_decoding.c:77)
 ==31771==    by 0x44B7B0: main (demuxing_decoding.c:323)
 ==31771==
 ==31771== LEAK SUMMARY:
 ==31771==    definitely lost: 3,976 bytes in 249 blocks
 ==31771==    indirectly lost: 56,352 bytes in 498 blocks
 ==31771==      possibly lost: 0 bytes in 0 blocks
 ==31771==    still reachable: 40 bytes in 1 blocks
 ==31771==         suppressed: 0 bytes in 0 blocks
 ==31771== Reachable blocks (those to which a pointer was found) are not
 shown.
 ==31771== To see them, rerun with: --leak-check=full --show-leak-kinds=all
 ==31771==
 ==31771== For counts of detected and suppressed errors, rerun with: -v
 ==31771== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 2 from 2)
 }}}

 This is reproducible with {{{-refcount=new_norefcount}}} but not
 {{{-refcount=new_refcount}}}.

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


More information about the FFmpeg-trac mailing list