#3194(avcodec:new): valgrind leak on example package
#3194: valgrind leak on example package ---------------------------------+---------------------------------- Reporter: andreyv | Type: defect Status: new | Priority: normal Component: avcodec | Version: 2.1.1 Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ---------------------------------+---------------------------------- Hi I've found valgrind leak when making and running valgrind on examples/decoding_encoding from latest 2.1 branch. A small example is in doc/example , called decoding_encoding Leak summary: ==22764== 56 bytes in 1 blocks are possibly lost in loss record 1 of 1 ==22764== at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==22764== by 0x85753B0: av_malloc (in /usr/ffmpeg/build/LibFFMPEG/ffmpeg-2.1/doc/examples/decoding_encoding) ==22764== by 0x807A353: video_decode_example (decoding_encoding.c:107) ==22764== by 0x807A3FF: main (decoding_encoding.c:174) Actually, I have the same issue in my big application. I switched from 0.8 branch to 2.1 branch, changed API and most of the files decoded fine. However, I am working on a valgrind leak summary always in the same place for all codecs (actually it is start of decoder allocation). Why does it happening ? What I am doing wrong ? Could you help me with this issue ? How to reproduce: make 2.1 branch with or anything else , I tried many different configurations ./configure --prefix="/usr/ffmpeg/build/LibFFMPEG" --extra- ldflags="-L/usr/ffmpeg/build/LibFFMPEG/lib" --bindir="/usr/ffmpeg/build/LibFFMPEG/bin" --enable-pthreads --extra- libs="-ldl" --extra-cflags="-I/usr/ffmpeg/build/LibFFMPEG/include" --enable-nonfree --enable-gpl --disable-vaapi --disable-debug --disable- iconv --disable-doc --disable-encoders --enable-memalign-hack' 2. make examples from doc/examples 3 run valgrind --tool=memcheck --leak-check=full --show-reachable=yes --verbose --track-origins=yes ./decoding_encoding <example> <example> -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ---------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: 2.1.1 | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ---------------------------------+----------------------------------- Changes (by cehoyos): * keywords: => leak Comment: Is the leak reproducible with current FFmpeg git head? -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:1> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ---------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: 2.1.1 | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ---------------------------------+----------------------------------- Comment (by andreyv): Hi I've done the same on latest git The configuration this time is ./configure --prefix="/home/andrey/ffmpeg_sources/ffmpeg_latest" --extra- ldflags="-L/home/andrey/ffmpeg_build/lib" --bindir="/home/andrey/ffmpeg_build/bin" --enable-pthreads --extra- libs="-ldl" --extra-cflags="-I/home/andrey/ffmpeg_build/include" --enable- nonfree --enable-gpl --disable-vaapi --disable-iconv --enable-memalign- hack I've commented everything in decode_encode.c and attaching the copy of changed simple example I really do not require to see the problems in decoder or encoder. My problem is a leak on initialization stage. The previous branch my project was linked 0.8 has no this issue I am also ataching the valgrind output for you -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:2> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ---------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: 2.1.1 | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ---------------------------------+----------------------------------- Comment (by cehoyos): Why do you use {{{--enable-memalign-hack}}} ? Please also remove {{{--enable-pthreads --enable-nonfree}}} from your configure line, both have no effect. The relevant part of your valgrind output is: {{{ ==19116== 56 bytes in 1 blocks are possibly lost in loss record 1 of 1 ==19116== at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==19116== by 0x86816B0: av_malloc (mem.c:86) ==19116== by 0x808CB82: video_decode_example (decoding_encoding.c:557) ==19116== by 0x808CC9B: main (decoding_encoding.c:635) }}} Line 557 of decoding_encoding.c does not contain a call to av_malloc() or do I miss something? -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:3> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Changes (by cehoyos): * version: 2.1.1 => git-master -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:4> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by andreyv): It is no av_malloc there. It should be called from avcodec_open2. At least it seems to be. The leak in av_malloc as it assign more than enough maybe, that's not freed at the end I've not investigated from source code perspective, only from library usage -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:5> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by andreyv): Actually I passed my win32 project in Dr. memory and the leak exist there also only on init stage from avcodec_open2 -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:6> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by andreyv): I've tested with suggested arguments. However , it doesn't help to fix the leak ./configure --prefix=/home/andrey/ffmpeg_sources/ffmpeg_latest --extra- ldflags=-L/home/andrey/ffmpeg_build/lib --bindir=/home/andrey/ffmpeg_build/bin --extra-libs=-ldl --extra- cflags=-I/home/andrey/ffmpeg_build/include --enable-gpl --disable-vaapi --disable-iconv ==6788== 24 bytes in 1 blocks are still reachable in loss record 1 of 1 ==6788== at 0x402A420: memalign (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==6788== by 0x402A4DE: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==6788== by 0x86816A7: av_malloc (mem.c:94) ==6788== by 0x808CB22: video_decode_example (decoding_encoding.c:557) ==6788== by 0x808CC3B: main (decoding_encoding.c:635) line 557 is if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); exit(1); } the leak comes from the av_malloc, it is inside the allocation from avcodec_open2 -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:7> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by cehoyos): Please build with {{{--disable-optimizations}}} this should make the valgrind output more useful. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:8> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by andreyv): ok now the output: ==15887== 24 bytes in 1 blocks are still reachable in loss record 1 of 1 ==15887== at 0x402A420: memalign (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==15887== by 0x402A4DE: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==15887== by 0x874A4BC: av_malloc (mem.c:94) ==15887== by 0x84AFD9B: default_lockmgr_cb (utils.c:78) ==15887== by 0x84B867A: ff_lock_avcodec (utils.c:3240) ==15887== by 0x84B2500: avcodec_open2 (utils.c:1180) ==15887== by 0x8049ED2: video_decode_example (decoding_encoding.c:557) ==15887== by 0x8049FEB: main (decoding_encoding.c:635) -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:9> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by andreyv): I can't see why those functions are leaking ==15887== by 0x84AFD9B: default_lockmgr_cb (utils.c:78) ==15887== by 0x84B867A: ff_lock_avcodec (utils.c:3240) ==15887== by 0x84B2500: avcodec_open2 (utils.c:1180) The leak is small 26bytes. However, if you open 1000 decoders or 10000 it converts to be not so small -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:10> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 1 | ------------------------------------+----------------------------------- Changes (by tomerb): * analyzed: 0 => 1 Comment: The leak is caused by malloc(ing) a mutex in default_lockmgr_cb() upon first use, and never free(int) it. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:11> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package ------------------------------------+----------------------------------- Reporter: andreyv | Owner: Type: defect | Status: open Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: leak | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+----------------------------------- Changes (by tomerb): * cc: barletz@… (added) * status: new => open * reproduced: 0 => 1 -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:12> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package -------------------------------------+------------------------------------- Reporter: andreyv | Owner: Type: defect | er.anshul.maheshwari@… Priority: normal | Status: open Version: git-master | Component: avcodec Keywords: leak | Resolution: Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Changes (by er.anshul.maheshwari@…): * owner: => er.anshul.maheshwari@… Comment: Reproduced with git master, Given a patch for new api to destroy mutex. But is not very good patch, user will we required to call ff_destroy_lock_avcodec function. User who are using some older version of ffmpeg can get rid of this leak by passing there own lock, since problem is in default lock of avcodec. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:13> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3194: valgrind leak on example package -------------------------------------+------------------------------------- Reporter: andreyv | Owner: Type: defect | er.anshul.maheshwari@… Priority: normal | Status: open Version: git-master | Component: avcodec Keywords: leak | Resolution: Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Changes (by er.anshul.maheshwari@…): * cc: er.anshul.maheshwari@… (added) -- Ticket URL: <https://trac.ffmpeg.org/ticket/3194#comment:14> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg