Is it possible to change some valgrind warnings into errors?
In particular, I want to turn the probably lost
warning into an error.
In the valgrind manual I found only information about how to suppress warnings.
Is there a way to do what I want?
Look for function names and line numbers If you compile your program with the -g flag, Valgrind will show you the function names and line numbers where errors occur.
Yes, there are false positives with Valgrind, that's why it has suppression files for particular glibc and gcc versions, for example. The false positives may arise if you are using older valgrind with newer gcc and glibc, i.e., valgrind 3.3 with glibc 2.9.
In general, Valgrind detection of overflows in stack and global variables is weak to non-existant. Arguably, Valgrind is the wrong tool for that job. If you are on one of supported platforms, building with -fmudflap and linking with -lmudflap will give you much better results for these kinds of errors.
Sometimes, running a program (including with valgrind) can show a double-free error while in reality, it's a memory corruption problem (for example a memory overflow). The best way to check is to apply the advice detailed in the answers : How to track down a double free or corruption error in C++ with gdb.
Since valgrind release 3.9, you can use the below command line options to better control what leak to reports, and what leaks to consider as errors.
--show-leak-kinds=kind1,kind2,.. which leak kinds to show?
[definite,possible]
--errors-for-leak-kinds=kind1,kind2,.. which leak kinds are errors?
[definite,possible]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With