Skip to content

Add build and runtime support for gcc/clang sanitizers

Christopher Rob Jones requested to merge jonrob/Gaudi:AddSanitizerSupport into master

Adds support in Gaudi for activating santizers via the CMTCONFIG setting.

http://clang.llvm.org/docs/AddressSanitizer.html

http://clang.llvm.org/docs/LeakSanitizer.html

http://clang.llvm.org/docs/ThreadSanitizer.html

http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Uses the existing functionality to extend the type flag with subtypes. e.g.

x86_64-centos7-gcc7-dbg+asan 

will activate the address sanitizer on top of the x86_64-centos7-gcc7-dbg build

The main changes are :

  1. Add support for understanding four new subtypes, asan, lsan, tsan and ubsan which triggers the required compiler options for each to be added to the build flags. Defaults are provided but these can if required be changed via a CMake command line flag.

  2. Some runtime support is also required.

  • One is to set some environment variables, like ASAN_OPTIONS to pass runtime options to the sanitizers. Again some defaults are provided.
  • Some default suppression files are also provided to suppress warnings. So far I have only added a few for lsan, but support is there for the others as well.
  • In order for gaudirun.py applications to work, the relevant runtime library needs to be preloaded (because the binary that starts the job, python, is not built with the sanitizers). This is done by setting an environment variable which gaudrun.py uses to detect when a sanitizer is enabled and automatically preloads the required library.
  1. I also need a small patch to how genconf is run to, when sanitizers are enabled, to prevent errors from running genconf itself aborting the build.

Examples of the results, for a sub-set of LHCb QM tests are at

https://www.hep.phy.cam.ac.uk/~jonesc/lhcb/QMTests/Saved/Sanitizers

Edited by Christopher Rob Jones

Merge request reports