I am running valgrind memcheck as part of my unit tests. Valgrind issues an "Invalid read of size 8" for a specific test views and modifies the GOT (Global Offset Table) of the process. I would like to suppress this warning preferably for just the GOT (i.e. other "invalid reads" warnings should be issued). Is there a way to do this without defining a valgrind suppression file? As part of an argument I can pass to valgrind via CMake/CTest?
1 Answer
If you are sure that it is safe to suppress the error, then I suggest that you do the following.
- Run Valgrind with --gen-suppressions=all. The output/log file will contain a suppression clause that can be used in a suppression file.
- Create a suppression file for the test and copy the clause(s) generated in step 1. Modify the 'insert a suppression name here' bit to be something meaningful and unique.
- Review whether the depth of the callstack for the suppression is appropriate. If you run Valgrind on more than one platform you may need to either wildcard library paths or add more suppressions per platform.
- Update the test to run Valgrind using the suppression file, --suppressions=
-
That's what I wanted to avoid... I don't want to have to modify the suppression file whenever the implementation and expected stack trace changes.– smichakJan 29, 2019 at 13:25
-
You can use wildcards to give some flexibility (for instance if you run on SuSE and RedHat with different system lib paths/versions). However if you overdo the wildcards then you risk suppressing unrelated errors. Jan 29, 2019 at 14:36