HardenedBSD/crypto/openssl/NOTES-VALGRIND.md
Pierre Pronchery b077aed33b Merge OpenSSL 3.0.9
Migrate to OpenSSL 3.0 in advance of FreeBSD 14.0.  OpenSSL 1.1.1 (the
version we were previously using) will be EOL as of 2023-09-11.

Most of the base system has already been updated for a seamless switch
to OpenSSL 3.0.  For many components we've added
`-DOPENSSL_API_COMPAT=0x10100000L` to CFLAGS to specify the API version,
which avoids deprecation warnings from OpenSSL 3.0.  Changes have also
been made to avoid OpenSSL APIs that were already deprecated in OpenSSL
1.1.1.  The process of updating to contemporary APIs can continue after
this merge.

Additional changes are still required for libarchive and Kerberos-
related libraries or tools; workarounds will immediately follow this
commit.  Fixes are in progress in the upstream projects and will be
incorporated when those are next updated.

There are some performance regressions in benchmarks (certain tests in
`openssl speed`) and in some OpenSSL consumers in ports (e.g.  haproxy).
Investigation will continue for these.

Netflix's testing showed no functional regression and a rather small,
albeit statistically significant, increase in CPU consumption with
OpenSSL 3.0.

Thanks to ngie@ and des@ for updating base system components, to
antoine@ and bofh@ for ports exp-runs and port fixes/workarounds, and to
Netflix and everyone who tested prior to commit or contributed to this
update in other ways.

PR:		271615
PR:		271656 [exp-run]
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2023-06-23 18:53:36 -04:00

2.7 KiB

Notes on Valgrind

Valgrind is a test harness that includes many tools such as memcheck, which is commonly used to check for memory leaks, etc. The default tool run by Valgrind is memcheck. There are other tools available, but this will focus on memcheck.

Valgrind runs programs in a virtual machine, this means OpenSSL unit tests run under Valgrind will take longer than normal.

Requirements

  1. Platform supported by Valgrind See http://valgrind.org/info/platforms.html
  2. Valgrind installed on the platform See http://valgrind.org/downloads/current.html
  3. OpenSSL compiled See INSTALL.md

Running Tests

Test behavior can be modified by adjusting environment variables.

EXE_SHELL

This variable is used to specify the shell used to execute OpenSSL test programs. The default wrapper (util/wrap.pl) initializes the environment to allow programs to find shared libraries. The variable can be modified to specify a different executable environment.

EXE_SHELL=\
"`/bin/pwd`/util/wrap.pl valgrind --error-exitcode=1 --leak-check=full -q"

This will start up Valgrind with the default checker (memcheck). The --error-exitcode=1 option specifies that Valgrind should exit with an error code of 1 when memory leaks occur. The --leak-check=full option specifies extensive memory checking. The -q option prints only error messages. Additional Valgrind options may be added to the EXE_SHELL variable.

OPENSSL_ia32cap

This variable controls the processor-specific code on Intel processors. By default, OpenSSL will attempt to figure out the capabilities of a processor, and use it to its fullest capability. This variable can be used to control what capabilities OpenSSL uses.

As of valgrind-3.15.0 on Linux/x86_64, instructions up to AVX2 are supported. Setting the following disables instructions beyond AVX2:

OPENSSL_ia32cap=":0"

This variable may need to be set to something different based on the processor and Valgrind version you are running tests on. More information may be found in doc/man3/OPENSSL_ia32cap.pod.

Additional variables (such as VERBOSE and TESTS) are described in the file test/README.md.

Example command line:

$ make test EXE_SHELL="`/bin/pwd`/util/wrap.pl valgrind --error-exitcode=1 \
    --leak-check=full -q" OPENSSL_ia32cap=":0"

If an error occurs, you can then run the specific test via the TESTS variable with the VERBOSE or VF or VFP options to gather additional information.

$ make test VERBOSE=1 TESTS=test_test EXE_SHELL="`/bin/pwd`/util/wrap.pl \
   valgrind --error-exitcode=1 --leak-check=full -q" OPENSSL_ia32cap=":0"