Valgrind: disable conditional branch checking (or an entire library)

I am developing an application using the OpenSSL API. As you know, OpenSSL uses miriades of global variables that are accepted by Valgrind as errors ("conditional jump or move ...", etc.). Thus, Valgrind output gets clogged with errors from shared libraries. This is very inconvenient for debugging purposes, because every time I get:

More than X common errors detected. I do not inform anymore. The final error values ​​will be inaccurate. Correct your program!

Questions:

  • Can I disable party libraries ( -ssl and -lcrypto in my case) does Valgrind check memory?
  • OR Can I focus only on “clearly lost” mistakes?

    Thanks.

+5
source share
4 answers

Valgrind can be configured to suppress errors in libraries.

Details about this can be found here: http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress

From the web page above:

Note. The easiest way to add constraints is to use the -gen-suppressionions = yes option described in the "Basic Command-Line Options" section. This automatically generates suppression. However, for best results, you can edit the output of -gen-suppression = yes manually, in which case it would be advisable to read this section.

+1
source

Add option

--undef-value-errors=no 

works for me (hide all "Conditional jump or move depends on uninitialized value (s)").

See the Valgrind man page for more details.

+7
source

Please note that you can also disable warnings generated by your own faulty code if you disable / disable all checks in OpenSSL. For example, when you pass incompletely initialized structures to OpenSSL functions, this can also lead to "conditional jump or move ..." errors, and you probably want to see them.

+1
source

You need to compile OpenSSL with the PURIFY flag (-DPURIFY in CFLAGS) to get rid of errors. Do not use the version compiled this way in the final application for debugging purposes only, as it reduces the entropy used in different places.

For example, compile OpenSSL in debug mode with

 ./config -d no-static shared zlib -Wa,--noexecstack -DPURIFY -O0 -ggdb3 
+1
source

Source: https://habr.com/ru/post/1501664/


All Articles