[petsc-dev] Tip while using valgrind

Smith, Barry F. bsmith at mcs.anl.gov
Sat Sep 21 00:14:03 CDT 2019


  When using valgrind it is important to understand that it does not immediately make a report when it finds an uninitialized memory, it only makes a report when an uninitialized memory would cause a change in the program flow (like in an if statement). This is why sometimes it seems to report an uninitialized variable that doesn't make sense. It could be that the value at the location came from an earlier uninitialized location and that is why valgrind is reporting it, not because the reported location was uninitialized.  Using the valgrind option --track-origins=yes is very useful since it will always point back to the area of memory that had the uninitialized value.

 I'm sending this out because twice recently I've struggled with cases where the initialized location "traveled" a long way before valgrind reported it and my confusion as to how valgrind worked kept making me leap to the wrong conclusions.

   Barry




More information about the petsc-dev mailing list