6

I want suppress Valgrind's reporting of some "definitely lost" memory by the library I'm using. I have tried valgrind --gen-suppressions=yes ./a but it only prompts for errors such as "conditional jump or move depends on uninitialized value".

Is there a way to generate suppressions for straight-up memory leaks? If not, is it difficult to write them by hand? Valgrind's manpage seems to discourage it, at least for errors.

Bill
  • 640
  • 2
  • 8
  • 18

4 Answers4

3

Run valgrind with the --gen-suppressions=all and --log-file=memcheck.log options, and manually copy/paste the logged suppressions into the suppression file.

valgrind --leak-check=full --gen-suppressions=all --log-file=memcheck.log ./a 

If you find the output is mixed with the application output then redirect valigrind output to separate file descriptor: --log-fd=9 9>>memcheck.log

valgrind --leak-check=full --gen-suppressions=all --log-fd=9 ./a  9>>memcheck.log
serghei
  • 3,069
  • 2
  • 30
  • 48
2

To be prompted for leaks that aren't generating errors, you have to run

valgrind --leak-check=full --gen-suppressions=yes ./a 
Bill
  • 640
  • 2
  • 8
  • 18
0

There is a page on how you can generate such a file based on your errors https://wiki.wxwidgets.org/Valgrind_Suppression_File_Howto

It's not perfect, but you can start from it

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
-2

You can write a suppression file of your own (but it doesn't seem obvious) :

--suppressions=<filename> [default: $PREFIX/lib/valgrind/default.supp]

If the question was to disable an entire library, see this.

Valgrind's man page.

Community
  • 1
  • 1
Gauthier Boaglio
  • 10,054
  • 5
  • 48
  • 85