Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress valgrind warnings by the origin of the uninitialized values?

Tags:

valgrind

Valgrind will tell you the origin of the uninitialized values with the track-origins=yes option.

I tried to suppress these warnings but the problem is that data based on uninitialized values can propagate everywhere, causing warnings elsewhere too.

The solution would be suppressing by the origin of the uninitialized data. How can I do it? Is it possible? It seems suppress files only filter the stack trace only.

The reason I want this, that OpenSSL enhances randomness by using uninitialized values on purpose, and I want to test a release build with valgrind (so -DPURIFY is not an option).

like image 428
Calmarius Avatar asked Jul 24 '13 09:07

Calmarius


People also ask

How do you reduce errors in Valgrind?

To make it easier to write suppressions, you can use the --gen-suppressions=yes option which tells Valgrind to print out a suppression for each error that appears, which you can then copy into a suppressions file.

What is Valgrind suppression?

Valgrind is (mostly) a memory error detector for Linux. It's very good at finding leaks and uninitialised variables; unfortunately it's too good, and usually produces a number of false positives. It comes with suppression files which automatically silence some of these; but not enough, and none specific to wxGTK.

What does conditional jump mean in Valgrind?

Uninitialized value errors The error message "Conditional jump or move depends on uninitialized value(s)" essentially means Valgrind has determined that the result of your program depends on uninitialized memory. Sometimes you will also see the message "Use of uninitialized value of size N".


2 Answers

My initial read of your question is that you might be okay with disabling all uninitialized value errors, in which case --undef-value-errors=no would do the trick.

If you're looking for something piecemeal, some hasty testing seems to indicate using --gen-suppressions=yes, then answering y for the relevant outputs and dropping them in a suppressions file worked for me when fiddling with my openssl binary.

Also, you might find the answer to How do you tell Valgrind to completely suppress a particular .so file? useful.

like image 72
Arthur Shipkowski Avatar answered Nov 03 '22 08:11

Arthur Shipkowski


The solution would be suppressing by the origin of the uninitialized data. How can I do it? Is it possible? It seems suppress files only filter the stack trace only.

I had the same problem with OpenSSL. According to Tom Hughes on the Valgrind mailing list, its not possible. See Frame-level wildcard not matching in suppression rule?.

In my case, I was trying to use frame level wildcards to suppress findings on the memory touched by RAND_init_fips (the OpenSSL FIPS version of the problem). This does not work, though we would like it to work:

{
   RAND_init_fips_1
   Memcheck:Cond
   ...
   fun:RAND_init_fips
   ...
}

{
   RAND_init_fips_2
   Memcheck:Value8
   ...
   fun:RAND_init_fips
   ...
}

{
   RAND_init_fips_3
   Memcheck:Value4
   ...
   fun:RAND_init_fips
   ...
}
like image 39
jww Avatar answered Nov 03 '22 10:11

jww