[FFmpeg-devel] [PATCH] ffprobe: free string_validation_replacement.

Michael Niedermayer michaelni at gmx.at
Wed Dec 4 03:46:02 CET 2013


On Tue, Dec 03, 2013 at 09:41:29PM +0100, Stefano Sabatini wrote:
> On date Tuesday 2013-12-03 18:44:29 +0100, Michael Niedermayer encoded:
> > Fixes memleak in fate tests
> > 
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  ffprobe.c |    1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/ffprobe.c b/ffprobe.c
> > index 43f830b..7d5a2b5 100644
> > --- a/ffprobe.c
> > +++ b/ffprobe.c
> > @@ -364,6 +364,7 @@ static void writer_close(WriterContext **wctx)
> >      if ((*wctx)->writer->priv_class)
> >          av_opt_free((*wctx)->priv);
> >      av_freep(&((*wctx)->priv));
> > +    av_freep(&(*wctx)->string_validation_replacement);
> >      av_freep(wctx);
> >  }
> 
> Fixed differently, thanks.
> 
> valgrind --tool=memcheck --leak-check=full --show-reachable=yes --verbose --track-origins=yes ffprobe_g tests/lena.pnm  -show_streams
> 
> ==22461== 
> ==22461== HEAP SUMMARY:
> ==22461==     in use at exit: 184 bytes in 4 blocks
> ==22461==   total heap usage: 78 allocs, 74 frees, 531,444 bytes allocated
> ==22461== 
> ==22461== Searching for pointers to 4 not-freed blocks
> ==22461== Checked 9,126,896 bytes
> ==22461== 
> ==22461== 32 bytes in 1 blocks are still reachable in loss record 1 of 4
> ==22461==    at 0x4C2ABB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22461==    by 0x4E356AF: _dlerror_run (dlerror.c:141)
> ==22461==    by 0x4E350C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
> ==22461==    by 0xC40D06C: ??? (in /usr/lib/libtbb.so.2)
> ==22461==    by 0xC415483: ??? (in /usr/lib/libtbb.so.2)
> ==22461==    by 0xC4168E4: ??? (in /usr/lib/libtbb.so.2)
> ==22461==    by 0xC409602: ??? (in /usr/lib/libtbb.so.2)
> ==22461==    by 0x400F875: call_init.part.0 (dl-init.c:84)
> ==22461==    by 0x400F92F: _dl_init (dl-init.c:55)
> ==22461==    by 0x4001689: ??? (in /lib/x86_64-linux-gnu/ld-2.17.so)
> ==22461==    by 0x2: ???
> ==22461==    by 0x7FF00019A: ???
> ==22461== 
> 
> ==22461== 40 bytes in 1 blocks are still reachable in loss record 2 of 4
> ==22461==    at 0x4C2A896: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22461==    by 0x4C2A987: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22461==    by 0xF7B8C9: av_malloc (mem.c:94)
> ==22461==    by 0xB6DAA8: default_lockmgr_cb (utils.c:78)
> ==22461==    by 0xB77497: ff_lock_avcodec (utils.c:3240)
> ==22461==    by 0xB707CB: avcodec_open2 (utils.c:1180)
> ==22461==    by 0x62F84A: avformat_find_stream_info (utils.c:2752)
> ==22461==    by 0x440249: open_input_file (ffprobe.c:2281)
> ==22461==    by 0x440561: probe_file (ffprobe.c:2345)
> ==22461==    by 0x442285: main (ffprobe.c:2943)
> ==22461== 
> ==22461== 40 bytes in 1 blocks are still reachable in loss record 3 of 4
> ==22461==    at 0x4C2A896: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22461==    by 0x4C2A987: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22461==    by 0xF7B8C9: av_malloc (mem.c:94)
> ==22461==    by 0xB6DAA8: default_lockmgr_cb (utils.c:78)
> ==22461==    by 0xB7762C: avpriv_lock_avformat (utils.c:3272)
> ==22461==    by 0x5B565C: ff_tls_init (network.c:71)
> ==22461==    by 0x634F2A: avformat_network_init (utils.c:4024)
> ==22461==    by 0x441EEF: main (ffprobe.c:2875)
> 
> Can someone explain these ones?

yes, they are mutexes from the default lock manager

you can probably free them by calling av_lockmgr_register() with
NULL. But this is only safe when nothing else can use a lock manager
at the same time. Thus for example its not safe for a lib to call that
as another lib or the app might use a lock manager too.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131204/26e62efb/attachment.asc>


More information about the ffmpeg-devel mailing list