tango-controls / cppTango

Moved to gitlab
http://tango-controls.org
41 stars 34 forks source link

Integration with sanitizers #797

Closed mliszcz closed 2 years ago

mliszcz commented 3 years ago

As discussed in Tango Kernel meeting on 22-10-2020, it would be good to have sanitizer (ASan, TSan and UBSan) jobs in CI.

See https://github.com/google/sanitizers for more detail on sanitizers.

This can be integrated into cppTango in few steps:

t-b commented 3 years ago

Thanks for the issue.

Add two (or more?) jobs to Travis.

Didn't we want to add the jobs in github actions?

Here are the settings we use internally

  IF(${SANITIZER})
    MESSAGE(STATUS "Building with sanitizer support.")
    TARGET_COMPILE_OPTIONS(${libname} PRIVATE $<$<CONFIG:DEBUG>:-g -O2
                           -fsanitize=address -fsanitize=undefined -fsanitize=integer
                           -fsanitize=nullability -fno-omit-frame-pointer -fno-sanitize-recover=all
                           -fsanitize-recover=unsigned-integer-overflow>)
    TARGET_LINK_OPTIONS(${libname} PRIVATE $<$<CONFIG:DEBUG>:-fsanitize=address
                        -fsanitize=undefined -fsanitize=integer -fsanitize=nullability
                        -fno-omit-frame-pointer -fno-sanitize-recover=all
                        -fsanitize-recover=unsigned-integer-overflow>)
  ENDIF()

and called via

 - export UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/UBSAN.supp,log_path=$(pwd)/sanitizer.log
- DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/${MACOSX_XCODE_VERSION}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
- $callExecutable

This is designed for clang on MacOSX and uses UBSAN and ASAN.