0

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 1

0

If you are sure that it is safe to suppress the error, then I suggest that you do the following.

  1. Run Valgrind with --gen-suppressions=all. The output/log file will contain a suppression clause that can be used in a suppression file.
  2. 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.
  3. 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.
  4. Update the test to run Valgrind using the suppression file, --suppressions=
2
  • 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.
    – smichak
    Jan 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.
    – Paul Floyd
    Jan 29, 2019 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.