Using Memory Sanitizer with Libstdc++

Uninitialized Usage in libstdc++ filesystem?

This is a false positive.

You should report it as a Sanitizer bug; it appears to be similar to issue 1238.

Memory Sanitizer

From the clang santitizer documentation it is clear that it only deals with unitialized memory reads from dynamically allocated memory. Automatic memory is not part of sanitizer checks.

Memory sanitizer reports use-of-uninitialized-value in global object construction

This is probably already reported MemorySanitizer bug https://github.com/google/sanitizers/issues/542.

However it was closed with Status WontFix without much explanation.

It seems that you need to build instrumented C++ standard library to avoid false positives. From MemorySanitizer wiki:

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 to use libc++ for that purpose.

clang memory sanitizer; how to make it print source line numbers

With the address sanitizer I noticed that I needed to have these environment variables defined:

  • ASAN_OPTIONS=symbolize=1 (only needed when compiled with GCC > 4.8) and
  • ASAN_SYMBOLIZER_PATH=$(which llvm-symbolizer) I think the symbolizer is what you're looking for. It transforms symbols to file names with line numbers and columns.

On the memory sanitizer project website it reads:

Symbolization

Set MSAN_SYMBOLIZER_PATH environment variable to the path to
llvm-symbolizer binary (normally built with LLVM). MemorySanitizer
will use it to symbolize reports on-the-fly.

So you need MSAN_SYMBOLIZER_PATH to be set analogous to ASAN_SYMBOLIZER_PATH.



Related Topics



Leave a reply



Submit