BoostGSoC20 / ublas

Boost.uBlas
https://www.boost.org/doc/libs/release/libs/numeric/ublas
1 stars 2 forks source link

Add Memory Sanitizer Check to CI #12

Open coder3101 opened 4 years ago

coder3101 commented 4 years ago

Memory Sanitizer helps in finding uninitialized use of variables, leaks and other memory-related behaviour that causes can cause UB.

However, due to restricting nature of MEMSAN and limitations, it is only available with clang and is hard to setup correctly. From discussion on #11

I have added the memory sanitizer but here is a problem.

Not uBLAS.tensor but Boost. Test framework has an issue of memory-sanitizer use of uninitialized value. I am not sure if it is really a true issue or false positive of MEMSAN. See this error report from Memory Sanitizer. However, I see many Stackoverflow questions that mention false positives for MEMSAN. Even its wiki says some things to do before using MEMSAN.

If you want MemorySanitizer to work properly and not produce any false positives, you must ensure that all the code in your program and in libraries it uses is instrumented (i.e. built with -fsanitize=memory). In particular, you would need to link against MSan-instrumented C++ standard library. We recommend using libc++ for that purpose. See https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo

I even tried using libc++ and linked a demo code to it with sanitizer enabled and got uninitialized use of memory error for std::cout<<"Hello world". See this:

image

The current CI is failing for Linux Clang due to the above sanitizer reported an error in Boost. Test