#MSan memory sanitizer : how to

28 messages · Page 1 of 1 (latest)

hollow mirageBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

hollow mirageBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.

coral reef
#

why msan?

#

g++ main.c -o main -fsanitize=address,leak

#

these work out of the box on linux 🤷‍♂️

#

and what do you mean by "nothing"

#

because asan does work ¯_(ツ)_/¯

sullen dagger
#

Msan is specifically for catching uses of uninitialized variables, which is something other sanitizers apparently don't do

coral reef
#

managed to run it

#

but it doesnt detect the uninitialized variable

sullen dagger
coral reef
#
#include <stdio.h>

int main(int argc, char** argv) {
  int* a = new int[10];
  a[5] = 0;
  if (a[argc])
    printf("xx\n");
  return 0;
}
sullen dagger
coral reef
#

g++ main.cpp

#

not gcc

#

and clang++ instead of clang

#

this is c++

#

no but msan probably does some magic that requires the C++ standard library when you use new

#

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).

#

i didnt build libc++ with it and it works

#

because it just works with msan

coral reef
#

i didnt do anything