Skip to content

fix(build): enable sanitizer configuration

Description

All compilers now support a fancy option to instrument code to detect errors at runtime. They are activated using the compile flag "-fsanitize=". The most well known sanitizer is the address one, which can be VERY helpful, along the thread one, that can detect very hard to find race condition.

take a look at https://learn.microsoft.com/fr-fr/cpp/build/reference/fsanitize?view=msvc-170 or https://clang.llvm.org/docs/AddressSanitizer.html or https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html).

The goal is just to pass this options using a SIGHT_SANITIZE CMake option.

Functional specifications

Configuring with SIGHT_SANITIZE="address" should set the correct build flag and option.

Technical specifications

Just use CMake add_compile_option and add_link_options.

Test plan

Just build and run coreTest with it. There are race conditions that will be detected with SIGHT_SANITIZE="thread" and invalid references or outside scope stack variable use, detected with SIGHT_SANITIZE="address"