Just linking with libavformat make valgrind report possibly lost, should I worry?

45 Views Asked by At

I have this test program:

#include <libavformat/avformat.h>

AVFormatContext * formatContext = NULL;

int main( int argc, char* argv[] ) {
    if( formatContext ) {
        avformat_free_context( formatContext );
        formatContext = NULL;
    }
    return 0;
}

It just does nothing as formatContext pointer is null, it just make sure linker bind with libavformat.

compiled with gcc -o testmem src/main.c -lavformat

And checking with valgrind --tool=memcheck --leak-check=full --leak-resolution=med --track-origins=yes --show-leak-kinds=all ./testmem

Report:

==13956== LEAK SUMMARY:
==13956==    definitely lost: 0 bytes in 0 blocks
==13956==    indirectly lost: 0 bytes in 0 blocks
==13956==      possibly lost: 1,352 bytes in 18 blocks
==13956==    still reachable: 48,092 bytes in 233 blocks
==13956==                       of which reachable via heuristic:
==13956==                         newarray           : 1,536 bytes in 16 blocks
==13956==         suppressed: 0 bytes in 0 blocks
==13956== 
==13956== For lists of detected and suppressed errors, rerun with: -s
==13956== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)

I understand it as "libavformat have some uninitialized pointer pointing at nothing".

Is there a missing ffmpeg cleanup function in my test program ?

Is this normal and I shall use a less paranoid set of options with valgrind ?

1

There are 1 best solutions below

0
Nelstaar On

After following @Paul advice I ended up using this valgrind suppression file.

{
   A
   Memcheck:Leak
   ...
   obj:/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.*
   ...
}

{
   B
   Memcheck:Leak
   ...
   obj:/lib/x86_64-linux-gnu/ld-2.31.so
   ...
}

with valgrind --tool=memcheck --leak-check=full --leak-resolution=med --track-origins=yes --show-leak-kinds=all --suppressions=testmem.supp ./testmem

I guess it's kind of specific to dev env.