2

Can someone please show me an example of how to add custom suppressions to valgrind? I am 99.99% sure it generates an error for the string class and I want to suppress the errors in a .supp file. I thought it would be simple enough just adding it to the directory or just adding my function to the default.supp but the error is not suppress. This is what I did:

1) I Ran valgrind with --gen-suppressions=yes 2) Obtained the generated suppression for my error listed below

  #Custom Suppression
  {
     MyCustomSupression
     Memcheck:Addr1
     fun:strlen
     fun:_ZNSsC1EPKcRKSaIcE
     obj:/home/steve/path/to/the/program
     obj:/home/steve/path/to/the/program
     obj:/home/steve/path/to/the/program
     obj:/home/steve/path/to/the/program
     obj:/home/steve/path/to/the/program
     obj:/home/steve/path/to/the/program
     obj:/home/steve/path/to/the/program
     fun:(below main)

}

3) I added the file to the directory where default.supp is located which is in my eclipse folder

4) I ran valgrind again but the error is still there

Note: I also tried adding the suppression to the default.supp file. Am I missing a step? What am I doing wrong?

2
  • "I am 99.99% sure it generates an error for the string class" Do you have a minimal example to demonstrate that? std::string should valgrind cleanly.
    – Baum mit Augen
    Feb 13, 2015 at 22:05
  • @BaummitAugen That probably depends on library, compiler, system and phase of moon. I have seen many std::string errors out of valgrind.
    – mjs
    Feb 13, 2015 at 22:11

1 Answer 1

3

I am pretty sure you need to specify the suppression file when you run valgrind, like this

##Generate suppressions
valgrind --gen-suppressions=yes myProgram
## Cut-Paste into string.supp
##Now rerun valgrind
valgrind --suppressions=./string.supp myProgram

See command line options for more detail.

4
  • I have done this (sorry, meant to include that bit) but i get the error: "FATAL: can't open suppressions file "string.supp"
    – srz2
    Feb 13, 2015 at 22:17
  • Did you specify the full path to the file? Please show the command you used.
    – mjs
    Feb 13, 2015 at 22:18
  • You know, that was my issue. I thought if I put it in the same directory, i wouldn't have to command the full path, but now that I did, I found it. I marked your answer as correct, but you woudln't know how to make it so i wouldn't have to give the full path, would you? just something more simplified?
    – srz2
    Feb 13, 2015 at 22:22
  • 1
    Put the suppression file in the directory where you are running valgrind from. Or in your home directory and use ~/string.supp.
    – mjs
    Feb 13, 2015 at 22:24

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.